このエントリーをはてなブックマークに追加

逆引き

IEの64bitの環境利用時のキー入力が遅い問題について

IE用の64bitのキー入力が実用に耐えられるレベルではないくらい遅いので32bitを利用する

「The driver is not executable」のメッセージが表示された時には

macにて以下のようなメッセージが表示された場合には

java.lang.IllegalStateException: The driver is not executable: chromedriver
   at com.google.common.base.Preconditions.checkState(Preconditions.java:469)

→ 対象のファイルに実行権限を付与する

# chmod +x chromedriver

$$を利用した際にnull pointer exception が表示される場合

Configuration.remoteに明確にnullを設定してやる。

# chmod +x chromedriver

chromeにてダウンロードダイアログを表示させずにダウンロードさせる場合

ダウンロード処理をさせる際にダイアログを表示させずに直接ダウンロードさせるにはWebDriverProviderの実装クラスを作成し 「Configuration.browser」へクラス名を設定する。

作成クラス例

/**
 * ファイルダウンロード用にWebDriverProviderを拡張
 *
 */
public static class ChromeCustomWebDriverProvider implements WebDriverProvider {

    private String downloadDirPath = "/*ダウンロード先のパスを設定する*/";

    @Override
    public WebDriver createDriver(DesiredCapabilities capabilities) {

        ChromeOptions op = new ChromeOptions();
        Map<String, Object> prefs = new HashMap<>();
        prefs.put("profile.default_content_settings.popups", 1);
        prefs.put("download.default_directory", downloadDirPath);
        op.setExperimentalOption("prefs", prefs);
        WebDriver driver = new ChromeDriver(op);
        return driver;
    }
}

利用先

Configuration.browser = ChromeCustomWebDriverProvider.class.getName();