API
ドライバ
Google Chrome
- Downloads - ChromeDriver - WebDriver for Chrome
- Capabilities & ChromeOptions - ChromeDriver - WebDriver for Chrome
- User Data Directory
Mozilla Firefox
以下のような場合を想定。
- ファイルダウンロード時に確認ダイアログを出さない(blob)
- プロファイルのパスを指定(Cookieを使用したいため)
Gebを使った例を載せておきます。
System.setProperty('webdriver.gecko.driver', 'path/to/geckodriver')
environments {
firefox {
driver = {
FirefoxOptions options = new FirefoxOptions()
FirefoxProfile profile = new FirefoxProfile(new File("/path/to/profile"))
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")
options.setProfile(profile)
new FirefoxDriver(options)
}
}
}
Microsoft Edge
- WebDriver - Microsoft Edge Development
- Webdriver - Microsoft Edge Development | Microsoft Docs
- EdgeDriver
Page Objectパターン
ページをオブジェクトとして考えるデザインパターンです。
同じページに対して、正常ケースとエラーケースで結果が異なる場合の扱い
PageObjectsによれば、Summaryとして以下の6点が書かれている。
- The public methods represent the services that the page offers
- Try not to expose the internals of the page
- Generally don’t make assertions
- Methods return other PageObjects
- Need not represent an entire page
- Different results for the same action are modelled as different methods
よって、メソッドはPageObjectsを返して、Assertionは呼び出し元で行うべき。