Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion selcukes-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</dependency>
<dependency>
<groupId>io.github.selcukes</groupId>
<artifactId>webdriver-binaries</artifactId>
<artifactId>selcukes-commons</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import io.appium.java_client.android.AndroidDriver;
import io.github.selcukes.commons.config.ConfigFactory;
import io.github.selcukes.wdb.enums.DriverType;
import lombok.CustomLog;
import lombok.SneakyThrows;
import org.openqa.selenium.Capabilities;
Expand Down Expand Up @@ -62,7 +61,7 @@ public WebDriver createBrowserDriver(String browser) {
Capabilities capabilities = AppiumOptions.getUserOptions();
if (capabilities == null) {
String platform = ConfigFactory.getConfig().getMobile().getPlatform();
capabilities = BrowserOptions.getBrowserOptions(DriverType.valueOf(browser), isCloudAppium(), platform);
capabilities = BrowserOptions.getBrowserOptions(BrowserOptions.valueOf(browser), platform);
if (isCloudAppium()) {
capabilities = capabilities.merge(CloudOptions.getBrowserStackOptions(false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,73 +17,70 @@
package io.github.selcukes.core.driver;

import io.github.selcukes.databind.utils.StringHelper;
import io.github.selcukes.wdb.WebDriverBinary;
import io.github.selcukes.wdb.enums.DriverType;
import lombok.experimental.UtilityClass;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeOptions;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerOptions;
import org.openqa.selenium.remote.Browser;

import static org.openqa.selenium.remote.Browser.CHROME;
import static org.openqa.selenium.remote.Browser.EDGE;
import static org.openqa.selenium.remote.Browser.FIREFOX;
import static org.openqa.selenium.remote.Browser.IE;

@UtilityClass
public class BrowserOptions {
public Capabilities getBrowserOptions(DriverType driverType, boolean ignoreBinarySetup) {
return getBrowserOptions(driverType, ignoreBinarySetup, "");
}
public static final String HEADLESS = "--headless";

public static Capabilities getBrowserOptions(DriverType driverType, boolean ignoreBinarySetup, String platform) {
boolean headless = RunMode.isHeadless();
if (!ignoreBinarySetup) {
setBinaries(driverType);
public static Capabilities getBrowserOptions(Browser browser, String platform) {
boolean isHeadless = RunMode.isHeadless();
if (EDGE.equals(browser)) {
EdgeOptions edgeOptions = new EdgeOptions();
if (isHeadless) {
edgeOptions.addArguments(HEADLESS);
}
if (!StringHelper.isNullOrEmpty(platform)) {
edgeOptions.setPlatformName(platform);
}
return edgeOptions;
} else if (FIREFOX.equals(browser)) {
FirefoxOptions firefoxOptions = new FirefoxOptions();
if (isHeadless) {
firefoxOptions.addArguments(HEADLESS);
}
return firefoxOptions;
} else if (IE.equals(browser)) {
InternetExplorerOptions ieOptions = new InternetExplorerOptions().requireWindowFocus();
ieOptions.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
ieOptions.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
ieOptions.setCapability("ignoreProtectedModeSettings", true);
ieOptions.setCapability("disable-popup-blocking", true);
ieOptions.setCapability("enablePersistentHover", true);
return ieOptions;
}

switch (driverType) {
case EDGE:

EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.setHeadless(headless);
if (!StringHelper.isNullOrEmpty(platform)) {
edgeOptions.setPlatformName(platform);
}
return edgeOptions;
case FIREFOX:
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setHeadless(headless);
return firefoxOptions;
case IEXPLORER:
InternetExplorerOptions ieOptions = new InternetExplorerOptions().requireWindowFocus();
ieOptions.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
ieOptions.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
ieOptions.setCapability("ignoreProtectedModeSettings", true);
ieOptions.setCapability("disable-popup-blocking", true);
ieOptions.setCapability("enablePersistentHover", true);
return ieOptions;
default:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setHeadless(headless);
if (!StringHelper.isNullOrEmpty(platform)) {
chromeOptions.setPlatformName(platform);
}
return chromeOptions;
ChromeOptions chromeOptions = new ChromeOptions();
if (isHeadless) {
chromeOptions.addArguments(HEADLESS);
}
if (!StringHelper.isNullOrEmpty(platform)) {
chromeOptions.setPlatformName(platform);
}
return chromeOptions;

}

public static void setBinaries(DriverType driverType) {
switch (driverType) {
case EDGE:
WebDriverBinary.edgeDriver().setup();
break;
case FIREFOX:
WebDriverBinary.firefoxDriver().setup();
break;
case IEXPLORER:
WebDriverBinary.ieDriver().setup();
break;
default:
WebDriverBinary.chromeDriver().setup();
public Browser valueOf(String browserName) {
if (browserName.equalsIgnoreCase("Edge")) {
return EDGE;
} else if (browserName.equalsIgnoreCase("IE")) {
return IE;
} else if (browserName.equalsIgnoreCase("Firefox")) {
return FIREFOX;
} else {
return CHROME;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@

package io.github.selcukes.core.driver;

import io.github.selcukes.wdb.enums.DriverType;
import lombok.CustomLog;
import lombok.experimental.UtilityClass;
import org.openqa.selenium.grid.Main;
import org.openqa.selenium.net.PortProber;

import java.util.Arrays;

import static io.github.selcukes.core.driver.RunMode.isCloudAppium;
import static io.github.selcukes.core.driver.RunMode.isCloudBrowser;
import static io.github.selcukes.core.driver.RunMode.isLocalBrowser;
Expand All @@ -34,10 +31,9 @@ public class GridRunner {
static int hubPort;
private static boolean isRunning = false;

public synchronized void startSelenium(DriverType... driverType) {
public synchronized void startSelenium() {
if (!isCloudBrowser() || !isLocalBrowser()) {
logger.info(() -> "Starting Selenium Server ...");
Arrays.stream(driverType).distinct().forEach(BrowserOptions::setBinaries);
hubPort = PortProber.findFreePort();
if (isSeleniumServerNotRunning()) {
logger.debug(() -> "Using Free Hub Port: " + hubPort);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.github.selcukes.core.driver;

import io.github.selcukes.commons.config.ConfigFactory;
import io.github.selcukes.wdb.enums.DriverType;
import lombok.CustomLog;
import lombok.SneakyThrows;
import org.openqa.selenium.Capabilities;
Expand All @@ -40,8 +39,7 @@ public synchronized WebDriver createDriver() {
logger.debug(() -> "Initiating New Browser Session...");
Capabilities capabilities = AppiumOptions.getUserOptions();
if (capabilities == null) {
capabilities = BrowserOptions.getBrowserOptions(DriverType.valueOf(browser),
!(isLocalBrowser() || isCloudBrowser()));
capabilities = BrowserOptions.getBrowserOptions(BrowserOptions.valueOf(browser), "");
if (isCloudBrowser()) {
capabilities = capabilities.merge(CloudOptions.getBrowserStackOptions(false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
package io.github.selcukes.core.tests.unit;

import io.github.selcukes.core.page.WebPage;
import io.github.selcukes.wdb.driver.LocalDriver;
import io.github.selcukes.wdb.enums.DriverType;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand All @@ -32,7 +32,9 @@ public class ShadowRootTest {

@BeforeMethod
private void setup() {
driver = new LocalDriver().createWebDriver(DriverType.CHROME);
var options = new ChromeOptions();
options.addArguments("--headless");
driver = new ChromeDriver(options);
page = new WebPage(driver);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import io.github.selcukes.commons.config.ConfigFactory;
import io.github.selcukes.core.driver.GridRunner;
import io.github.selcukes.core.page.Pages;
import io.github.selcukes.wdb.enums.DriverType;
import lombok.CustomLog;
import org.openqa.selenium.remote.Browser;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
Expand All @@ -31,19 +31,19 @@
public class ClassicGridTest {
@BeforeSuite
public static void beforeSuite() {
GridRunner.startSelenium(DriverType.CHROME, DriverType.EDGE);
GridRunner.startSelenium();
}

@DataProvider(parallel = true)
public Object[][] driverTypes() {
return new Object[][] { { DriverType.CHROME }, { DriverType.EDGE }
return new Object[][] { { Browser.CHROME }, { Browser.EDGE }
};
}

@Test(dataProvider = "driverTypes")
public void parallelBrowserTest(DriverType driverType) {
logger.debug(() -> "In Parallel Test for " + driverType.getName());
ConfigFactory.getConfig().getWeb().setBrowser(driverType.getName());
public void parallelBrowserTest(Browser driverType) {
logger.debug(() -> "In Parallel Test for " + driverType.browserName());
ConfigFactory.getConfig().getWeb().setBrowser(driverType.browserName());
Pages.webPage().open("https://www.google.com/")
.assertThat().title("Google");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import io.github.selcukes.commons.helper.FileHelper;
import io.github.selcukes.core.page.WebPage;
import io.github.selcukes.databind.utils.Clocks;
import io.github.selcukes.wdb.driver.LocalDriver;
import io.github.selcukes.wdb.enums.DriverType;
import lombok.CustomLog;
import lombok.SneakyThrows;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand All @@ -43,7 +43,9 @@ public class EventDriverTest {

@BeforeMethod
private void setup() {
driver = new LocalDriver().createWebDriver(DriverType.CHROME);
var options = new ChromeOptions();
options.addArguments("--headless");
driver = new ChromeDriver(options);
page = new WebPage(driver);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

import io.github.selcukes.core.page.WebPage;
import io.github.selcukes.core.wait.WaitCondition;
import io.github.selcukes.wdb.driver.LocalDriver;
import io.github.selcukes.wdb.enums.DriverType;
import lombok.CustomLog;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
Expand All @@ -37,7 +37,9 @@ public class WebAuthTest {

@BeforeMethod
private void setup() {
driver = new LocalDriver().createWebDriver(DriverType.CHROME);
var options = new ChromeOptions();
options.addArguments("--headless");
driver = new ChromeDriver(options);
page = new WebPage(driver);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,18 @@
public class CsvMapper {

/**
* It takes a CSV file, reads it line by line, splits each line by comma, removes the quotes, and returns a list of
* maps
* It takes a CSV file, reads it line by line, splits each line by comma,
* removes the quotes, and returns a list of maps
*
* @param filePath The path to the file to be parsed.
* @return A list of maps.
* @param filePath The path to the file to be parsed.
* @return A list of maps.
*/
public List<Map<String, String>> parse(Path filePath) {
try (var lines = Files.lines(filePath)) {
return Streams.toListOfMap(lines.parallel()
.map(line ->
Pattern.compile(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)").splitAsStream(line)
.map(field -> field.replaceAll("^\"|\"$", ""))
.collect(Collectors.toCollection(LinkedList::new)))
.map(line -> Pattern.compile(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)").splitAsStream(line)
.map(field -> field.replaceAll("^\"|\"$", ""))
.collect(Collectors.toCollection(LinkedList::new)))
.collect(Collectors.toCollection(LinkedList::new)));
} catch (Exception e) {
throw new DataMapperException("Failed parsing CSV File: ", e);
Expand Down
Loading