我正在寻找一个选项,可以使用SelenIDE / JUNIT / Maven在INCOGNITO中打开铬以进行自动化测试。
我不确定我需要在此处提供什么样的信息。我将添加一个LocalTest页面的副本,该页面将引导WebdriverRunner。
我在测试类中调用实际的网址,因为该站点有不同的要测试的起点。
这就是我调用网址的方式:
public class LocalTest extends SelenideHelperClass {
private static Logger logger = LoggerFactory.getLogger(LocalTest.class);
private static boolean osIs(String os) {
return System.getProperty("os.name").toLowerCase().contains(os);
}
@BeforeClass
public static void setupDriver() {
if (System.getProperty("CHROMEDRIVER_HOME") != null) {
System.setProperty("webdriver.chrome.driver", System.getProperty("CHROMEDRIVER_HOME") + "/chromedriver");
} else if (System.getenv("CHROMEDRIVER_HOME") != null) {
System.setProperty("webdriver.chrome.driver", System.getenv("CHROMEDRIVER_HOME") + "/chromedriver");
} else {
String driver;
if (osIs("mac")) {
driver = "chromedriver-mac";
} else if (osIs("windows")) {
driver = "chromedriver.exe";
} else if (osIs("linux")) {
driver = "chromedriver-linux";
} else {
throw new RuntimeException("OS could not be determined, chromedriver cannot be set or is unavailable");
}
System.setProperty("webdriver.chrome.driver", System.getProperty("java.io.tmpdir") + "/chromedriver/" + driver);
}
System.setProperty("selenide.browser", "Chrome");
logger.info("Set selenide.browser to Chrome");
logger.info("Set webdriver.chrome.driver to " + System.getProperty("webdriver.chrome.driver"));
// ----------------
}
@AfterClass
public static void closeDriver() {
WebDriverRunner.getWebDriver().quit();
}
}
我希望数量很多,但是如果我需要提供更多信息,我将随时准备回答。
LocalTest的副本
root@:~/elo# cat test | grep name | grep -v expand | cut -c 22- | rev | cut -c 3- | rev
service1
service2
root@:~/elo# cat test | grep customfield | cut -c 31- | rev | cut -c 2- | rev
2.3.4
55.66
答案 0 :(得分:0)
我找到了解决方法:
...
} else {
throw new RuntimeException("OS could not be determined, chromedriver cannot be set or is unavailable");
}
ChromeOptions option = new ChromeOptions();
option.addArguments("start-maximized");
option.addArguments("incognito");
System.setProperty("webdriver.chrome.driver", System.getProperty("java.io.tmpdir") + "/chromedriver/" + driver);
ChromeDriver webdriver = new ChromeDriver(option);
WebDriverRunner.setWebDriver(webdriver);
}
System.setProperty("selenide.browser", "Chrome");
logger.info("Set selenide.browser to Chrome");
logger.info("Set webdriver.chrome.driver to " + System.getProperty("webdriver.chrome.driver"));
}
....