1
我在Mozilla上使用Selenium IDE來測試一個網站。之後,我在Eclipse中創建了一個Java項目,並使用Selenium IDE導入了我的測試。那麼我直接在Eclipse中運行它。Selnium + Firefox到Selenium + PhantomJS
如何使用PhantomJS而不是Mozilla Firefox來運行測試?
我在Mozilla上使用Selenium IDE來測試一個網站。之後,我在Eclipse中創建了一個Java項目,並使用Selenium IDE導入了我的測試。那麼我直接在Eclipse中運行它。Selnium + Firefox到Selenium + PhantomJS
如何使用PhantomJS而不是Mozilla Firefox來運行測試?
您有兩種方法可以在phantomjs中運行測試,但首先必須在某處安裝/解壓縮phantomjs並將PATH變量擴展到它。
第一:您可以通過Maven的pom.xml
在here
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>LATEST_VERSION_HERE</version>
</dependency>
使用Ghostdriver Java綁定(您需要在您的Eclipse項目庫)等,然後實例化你的webdriver這樣:
WebDriver driver = new PhantomJSDriver();
第二:在webdriver的模式下運行phantomjs(在單獨的控制檯窗口或作爲快捷方式)通過量^ h
phantomjs --webdriver=4444
像here然後通過實例化的webdriver在Java:
WebDriver driver = new RemoteWebDriver(
new Uri("http://127.0.0.1:4444/wd/hub"),
DesiredCapabilities.phantomjs()
);
又見用作hub另一個問題。
請更清楚你實際上想要做什麼?你在尋找什麼樣的最終結果? – Deepend