use of org.openqa.selenium.edge.EdgeDriver in project SeleniumMaven by jagadeeshshetty.
the class Base method setup.
@BeforeMethod
public void setup(ITestContext context) {
step("Start time: " + getDateTime("d MMM uuuu HH:mm:ss"));
step("Running Test on '" + System.getProperty("os.name") + "' OS.");
step("JVM Version: " + System.getProperty("java.version"));
step("Browser: " + browser.toUpperCase());
switch(browser) {
case "firefox":
WebDriverManager.firefoxdriver().setup();
driver.set(new FirefoxDriver());
break;
case "chromeHeadless":
WebDriverManager.chromedriver().setup();
chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--headless");
driver.set(new ChromeDriver(chromeOptions));
break;
case "chrome":
WebDriverManager.chromedriver().setup();
chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-dev-shm-usage");
driver.set(new ChromeDriver(chromeOptions));
break;
case "edge":
WebDriverManager.edgedriver().setup();
driver.set(new EdgeDriver());
break;
case "ie":
WebDriverManager.iedriver().setup();
driver.set(new InternetExplorerDriver());
break;
case "opera":
WebDriverManager.operadriver().setup();
driver.set(new OperaDriver());
break;
case "safari":
driver.set(new SafariDriver());
break;
default:
step("No proper browser specified.");
logger.info("No proper browser specified.");
}
if (driver != null) {
step("Driver instance: " + getDriver().toString());
getDriver().manage().timeouts().pageLoadTimeout(GlobalConfig.pageLoadTimeoutInSec, TimeUnit.SECONDS);
context.setAttribute("WebDriver", getDriver());
context.setAttribute("logger", logger);
}
}
use of org.openqa.selenium.edge.EdgeDriver in project Selenium_April_2022 by TestLeafPages.
the class ProjectSpecificMethods method startBrowser.
@Parameters({ "browserName", "URL" })
@BeforeMethod
public void startBrowser(String browserName, String url) {
if (browserName.equals("Chrome")) {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
} else if (browserName.equals("Edge")) {
WebDriverManager.edgedriver().setup();
driver = new EdgeDriver();
}
driver.manage().window().maximize();
driver.get(url);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
}
use of org.openqa.selenium.edge.EdgeDriver in project testbench by vaadin.
the class LocalDriver method createDriver.
/**
* Creates a {@link WebDriver} instance used for running the test locally
* for debug purposes.
*/
public static WebDriver createDriver(DesiredCapabilities desiredCapabilities) {
WebDriver driver;
if (BrowserUtil.isFirefox(desiredCapabilities)) {
String firefoxPath = System.getProperty("firefox.path");
String profilePath = System.getProperty("firefox.profile.path");
FirefoxOptions options = new FirefoxOptions();
if (firefoxPath != null) {
options.setBinary(new FirefoxBinary(new File(firefoxPath)));
}
if (profilePath != null) {
File profileDir = new File(profilePath);
FirefoxProfile profile = new FirefoxProfile(profileDir);
options.setProfile(profile);
}
options.setHeadless(Parameters.isHeadless());
driver = new FirefoxDriver(options);
} else if (BrowserUtil.isChrome(desiredCapabilities)) {
// Tells chrome not to show warning
// "You are using an unsupported command-line flag:
// --ignore-certifcate-errors".
// #14319
ChromeOptions options = new ChromeOptions();
options.addArguments("--test-type ");
options.setHeadless(Parameters.isHeadless());
driver = new ChromeDriver(options);
} else if (BrowserUtil.isSafari(desiredCapabilities)) {
driver = new SafariDriver();
} else if (BrowserUtil.isEdge(desiredCapabilities)) {
driver = new EdgeDriver();
} else if (BrowserUtil.isIE(desiredCapabilities)) {
driver = new InternetExplorerDriver();
} else {
throw new RuntimeException("Not implemented support for running locally on " + desiredCapabilities.getBrowserName());
}
return TestBench.createDriver(driver);
}
use of org.openqa.selenium.edge.EdgeDriver in project selenium-webdriver-java by bonigarcia.
the class ConsoleEventsEdgeSelJupTest method testConsoleEvents.
@Test
void testConsoleEvents(EdgeDriver driver) throws InterruptedException {
HasLogEvents logger = (HasLogEvents) driver;
CountDownLatch latch = new CountDownLatch(4);
logger.onLogEvent(CdpEventTypes.consoleEvent(consoleEvent -> {
log.debug("{} {}: {}", consoleEvent.getTimestamp(), consoleEvent.getType(), consoleEvent.getMessages());
latch.countDown();
}));
driver.get("https://bonigarcia.dev/selenium-webdriver-java/console-logs.html");
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
}
use of org.openqa.selenium.edge.EdgeDriver in project selenium-webdriver-java by bonigarcia.
the class DomMutationEdgeSelJupTest method testDomMutation.
@Test
void testDomMutation(EdgeDriver driver) throws InterruptedException {
driver.get("https://bonigarcia.dev/selenium-webdriver-java/");
HasLogEvents logger = (HasLogEvents) driver;
JavascriptExecutor js = (JavascriptExecutor) driver;
AtomicReference<DomMutationEvent> seen = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
logger.onLogEvent(CdpEventTypes.domMutation(mutation -> {
seen.set(mutation);
latch.countDown();
}));
WebElement img = driver.findElement(By.tagName("img"));
String newSrc = "img/award.png";
String script = String.format("arguments[0].src = '%s';", newSrc);
js.executeScript(script, img);
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
assertThat(seen.get().getElement().getAttribute("src")).endsWith(newSrc);
}
Aggregations