RemoteWebDriver使用說明


1. 本地代碼使用RemoteWebDriver啟動:

 public class Testing {
    public void myTest()throws Exception {
       WebDriver driver = newRemoteWebDriver(new URL("http://localhost:4444/wd/hub"),DesiredCapabilities.firefox());
       driver.get("http://www.google.com");
        // RemoteWebDriverdoes not implement the TakesScreenshot class
        // if the driver doeshave the Capabilities to take a screenshot
        // then Augmenter willadd the TakesScreenshot methods to the instance
        WebDriver augmentedDriver = new Augmenter().augment(driver);
        File screenshot =((TakesScreenshot)augmentedDriver).getScreenshotAs(OutputType.FILE);
    }
}

2. Remote機器上啟動監聽端口

java -jar selenium-server-standalone-2.46.0.jar -port 4444

3. 執行

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM