提交 55fa477b authored 作者: 黄夏豪's avatar 黄夏豪

[web驱动] 更新了火狐的驱动程序

[目录结构] 更新了代码目录结构更加合理了
上级 3f517f56
No preview for this file type
package com.example.seleniumtest.selenium.util;
package com.example.seleniumtest.selenium;
import com.example.seleniumtest.WebDriverUtil;
import com.example.seleniumtest.selenium.enums.Browser;
import com.example.seleniumtest.selenium.util.WebDriverUtil;
import org.openqa.selenium.WebDriver;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......@@ -10,7 +10,7 @@ public class SeleniumTestApplication {
public static void main(String[] args) {
// SpringApplication.run(SeleniumTestApplication.class, args);
WebDriver driver = WebDriverUtil.getWebDriver(Browser.CHROME, false);
WebDriver driver = WebDriverUtil.getWebDriver(Browser.FIREFOX, false);
driver.get("http://www.itest.info");
String title = driver.getTitle();
System.out.printf(title);
......
package com.example.seleniumtest;
package com.example.seleniumtest.selenium.util;
import com.example.seleniumtest.selenium.enums.Browser;
import org.openqa.selenium.WebDriver;
......@@ -39,13 +39,14 @@ public class WebDriverUtil {
switch (browser.toLowerCase()) {
case Browser.FIREFOX:
// /opt/apps/org.mozilla.firefox/files/lib/firefox-esr/firefox-esr
System.setProperty("webdriver.firefox.driver", WebDriverUtil.FIRE_FOX + executable);
System.setProperty("webdriver.gecko.driver", WebDriverUtil.FIRE_FOX + executable);
// System.setProperty("webdriver.firefox.bin", "/home/hct/firefox/firefox");
FirefoxOptions firefoxOptions = new FirefoxOptions();
if (headless) {
firefoxOptions.addArguments("--headless");
}
firefoxOptions.setBinary("/opt/apps/org.mozilla.firefox/files/lib/firefox-esr/firefox-esr");
// firefoxOptions.setBinary("/opt/apps/org.mozilla.firefox/files/lib/firefox-esr/firefox-esr");
firefoxOptions.setBinary("C:/Program Files/Mozilla Firefox/firefox.exe");
return new FirefoxDriver(firefoxOptions);
case Browser.CHROME:
System.setProperty("webdriver.chrome.driver", WebDriverUtil.CHROME + executable);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论