Maitiro Ekumhanyisa WebDriver mune isina Musoro Mode

Maitiro ekumhanyisa WebDriver mune isina musoro modhi? Izvi zvinogona kudikanwa kana yako CI chishandiso, semuenzaniso, Jenkins haitsigire UI.

Kumhanya WebDriver Yakanongedzwa Miedzo mune isina musoro modhi inopa zvakanakira maererano nekumhanya kwekuitwa kwemiedzo uye nyore kubatanidzwa muCI pombi.

Mune ino dzidziso, isu tinoshandisa PhantomJS uye ChromeDriver kumhanya Selenium WebDriver bvunzo mune isina musoro modhi.

PhantomJS

Kuti umhanye Selenium WebDriver bvunzo mune isina musoro modhi uchishandisa PhantomJS, unofanira kutanga wadhanilodha PhantomJS inogoneka faira uye chengeta munzvimbo, i.e. dhairekitori rako rezvinhu zveprojekiti.

Mumuenzaniso pazasi, ini ndaisa iyo PhantomJS inoitwa mu src / test / resources / phantomjs

Iwe zvakare uchazoda chipoko mutyairi kutsamira futi:

com.github.detro.ghostdriver phantomjsdriver 1.0.1

Uye yako Java kirasi:

import org.openqa.selenium.phantomjs.PhantomJSDriver; import org.openqa.selenium.phantomjs.PhantomJSDriverService; import org.openqa.selenium.remote.DesiredCapabilities; public class WebDriverBase {
static protected WebDriver driver;

public static void setup() {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true); // not really needed: JS enabled by default
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, 'src/test/resources/phantomjs');

driver = new PhantomJSDriver(caps);
}

public static void main(String[] args) {
WebDriverBase.setup();
driver.get('https://devqa.io');
} }

ChromeDriver

Kuti umhanye bvunzo dzeWebDriver mune isina musoro maitiro uchishandisa ChromeDriver, iwe unozofanirwa kuwedzera zvinoenderana zvinoenderana mune yako pom.xml faira:


org.seleniumhq.selenium
selenium-chrome-driver
${selenium.version}
org.seleniumhq.selenium
selenium-server
${selenium.version}
org.seleniumhq.selenium
selenium-java
${selenium.version}
io.github.bonigarcia
webdrivermanager
${webdrivermanager.version}

Tevere, tinoraira maneja weWebDriver kuvhura chrome mutyairi mune isina musoro modhi

import io.github.bonigarcia.wdm.ChromeDriverManager; import org.openqa.selenium.chrome.ChromeDriver; public class WebDriverBase {
static protected WebDriver driver;
public static void setup() {
ChromeDriverManager.getInstance().setup();
ChromeOptions chromeOptions = new ChromeOptions();

chromeOptions.addArguments('--headless');
driver = new ChromeDriver(chromeOptions);
}
public static void main(String[] args) {
WebDriverBase.setup();
driver.get('https://devqa.io');
} }