Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package seleniumutils;
- import java.util.List;
- import java.util.concurrent.TimeUnit;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.By.ById;
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.support.ui.WebDriverWait;
- public class SeleniumUtils {
- WebDriver driver;
- final String webUrl = "url";
- final String pathToChromeDriver = "path to chromedriver.exe";
- final String KEY_WEB_DRIVER = "webdriver.chrome.driver";
- WebDriverWait wait;
- public void initDriver() {
- System.setProperty(KEY_WEB_DRIVER, pathToChromeDriver);
- driver = new ChromeDriver();
- driver.get(webUrl);
- // driver.manage().timeouts().implicitlyWait(5000, TimeUnit.SECONDS);
- driver.manage().window().maximize();
- String str = driver.getCurrentUrl();
- System.out.println("The current URL is " + str);
- wait = new WebDriverWait(driver, 10);
- }
- public List < WebElement > getElementsByID(String id) {
- List < WebElement > list = (List < WebElement > ) driver.findElement(ById.id(id));
- return list;
- }
- public void waitForScanner(String lookup) {
- WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(driver.findElement(By.xpath(lookup))));
- }
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.interact-ez</groupId>
- <artifactId>interact-ez</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>interact-ez</name>
- <url>http://maven.apache.org</url>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.seleniumhq.selenium</groupId>
- <artifactId>selenium-java</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>6.8</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>io.appium</groupId>
- <artifactId>java-client</artifactId>
- <version>5.0.4</version>
- </dependency>
- </dependencies>
- </project>
Add Comment
Please, Sign In to add comment