3 回答
TA貢獻1796條經驗 獲得超4個贊
FirefoxDrivergeckodriver
geckodriverwireswebdriver.gecko.driver
System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver");<dependency> <groupId>io.github.bonigarcia</groupId> <artifactId>webdrivermanager</artifactId> <version>3.6.1</version></dependency>
WebDriverManager.firefoxdriver().setup();
public class FirefoxTest {
protected WebDriver driver;
@BeforeClass
public static void setupClass() {
WebDriverManager.firefoxdriver().setup();
}
@Before
public void setupTest() {
driver = new FirefoxDriver();
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void test() {
// Your test code here
}}更新
FirefoxDriver
TA貢獻1757條經驗 獲得超7個贊
從 解壓檔案 為Marionette創建一個目錄(即, mkdir -p /opt/marionette)將解壓縮的可執行文件移動到您創建的目錄中。 更新您的 $PATH若要包含可執行文件(同時,請編輯 .bash_profile如果你愿意的話) :邦邦:確保你 chmod +x /opt/marionette/wires-x.x.x所以它是可執行的 在啟動過程中,請確保使用以下代碼(這是我在Mac上使用的代碼)
速記
Java片段
WebDriver browser = new MarionetteDriver();System.setProperty("webdriver.gecko.driver", "/opt/marionette/wires-0.7.1-OSX");添加回答
舉報
