2

SerenityマネージドクロームドライバでNexus 5ビューのモバイルエミュレーションを設定するにはどうすればよいですか?クロムドライバのセレンティプロパティファイルにデバイス名を設定

私は、このリンクを通過しようとした:クロムのプリファレンスを設定する説明 https://johnfergusonsmart.com/configuring-chromedriver-easily-with-serenity-bdd/

を。このことから

Chrome preferences 
You can also provide more advanced options using the setExperimentalOption() method: 

Map<String, Object> chromePrefs = new HashMap<String, Object>(); 
chromePrefs.put("download.default_directory", downLoadDirectory); 
chromePrefs.put("profile.default_content_settings.popups", 0); 
chromePrefs.put("pdfjs.disabled", true); 
ChromeOptions options = new ChromeOptions(); 
options.setExperimentalOption("prefs", chromePrefs); 

In Serenity, you would pass these using properties prefixed with the chrome_preferences prefix, e.g. 

chrome_preferences.download.default_directory = /my/download/directory 
chrome_preferences.profile_default_content_settings.popups = 0 
chrome_preferences.pdfjs.disabled=true 

、私は

chrome.capabilities.mobile_emulation.device_name= Google Nexus 5 chrome.options.mobileEmulation.deviceName= Google Nexus 5

およびその他のいくつかの論理的なバリアントとしてmobileEmulationを設定しようとしたが、それらのどれも成功しません。

答えて

0

私は、この問題で私がカスタムWebDriverを作成するのに役立つ最良の方法を見つけました。

DriverSourceを拡張するクラスを作成する必要がありました。それをSerenity Propertiesファイルにリンクします。これは私に必要なドライバを与えるでしょう。

http://www.thucydides.info/docs/serenity/#_custom_webdriver_implementations

あなたは DriverSourceインタフェースを実装することで、独自のカスタムwebdriverをプロバイダを追加することができます。

webdriver.driver = provided 
webdriver.provided.type = mydriver 
webdriver.provided.mydriver = com.acme.MyPhantomJSDriver 
thucydides.driver.capabilities = mydriver 

ここ を示すようにDriverSourceインタフェースを実装する必要がありますあなたのカスタムドライバ、::

public class MyPhantomJSDriver implements DriverSource { 

    @Override 
    public WebDriver newDriver() { 
     try { 
      DesiredCapabilities capabilities = DesiredCapabilities.phantomjs(); 
      // Add 
      return new PhantomJSDriver(ResolvingPhantomJSDriverService.createDefaultService(), 

まず、次のようなシステム プロパティを設定する(例えば、あなたのserenity.properties内のファイル)が必要です能力) } catch(IOException e){ 新しいエラー(e)をスローします。 }}

 @Override 
    public boolean takesScreenshots() { 
     return true; 
    } 
} 

このドライバは現在、通常のスクリーンショットを取ります。

関連する問題