2017-10-16 12 views
2

Serenity 관리 크롬 드라이버에서 Nexus 5보기 용 모바일 에뮬레이션을 설정하려면 어떻게해야합니까? 크롬 설정을 기본 설정을 설명 https://johnfergusonsmart.com/configuring-chromedriver-easily-with-serenity-bdd/크롬 드라이버 용 serenity.properties 파일에 장치 이름 설정

을 :

나는이 링크를 통과했습니다. 이에서
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) { throw 새 오류 (e); } }

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

이 드라이버는 일반적으로 스크린 샷을 취할 것입니다.