2017-08-14 131 views
2
**Sinppet** 

if (os.contains("win")) { 
        System.out.println("OS: WINDOWS"); 
        System.setProperty("webdriver.chrome.driver", localPath+"chromedriver.exe"); 
        ChromeOptions chromeOptions = new ChromeOptions(); 
        chromeOptions.addArguments("headless"); 
        return new ChromeDriver(chromeOptions); 
       } else if (os.contains("mac")) { 
        System.out.println("OS: MAC");    
        System.setProperty("webdriver.chrome.driver", localPath+"chromedriver_mac64"); 
        return new ChromeDriver(); 
       } 
在Windows 7推出的Chrome模擬瀏覽器

錯誤,我面對無法使用Selenium

org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.xpath: //input[@id='user_id'] (tried for 180 second(s) with 500 MILLISECONDS interval) 
    at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:80) 
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:232) 
    at com.adp.marketplace.frwk.selenium.SeleniumFunctions.waitForVisibilityByXpath(SeleniumFunctions.java:510) 
    at com.adp.marketplace.prm.SSOTestInPRMSteps.The_user_logged_into_PRM_with_valid_cred(SSOTestInPRMSteps.java:28) 
    at ?.Given the user logged into PRM with valid creds(com/adp/marketplace/prm/SSOTestsInPRM.feature:7) 

回答

1

無頭的說法是不對的,應該是:

chromeOptions.addArguments("--headless"); 

帶 - - 無頭之前,就像你從快捷方式添加參數: enter image description here