Skip to content

Commit

Permalink
updating BrowserEmulator
Browse files Browse the repository at this point in the history
  • Loading branch information
vasgat committed Feb 8, 2021
1 parent 4458c9b commit 00c47d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.WebDriverWait;

/**
* @author vasgat
Expand All @@ -33,24 +35,26 @@ public class BrowserEmulator extends Fetcher {

public WebDriver driver;

public BrowserEmulator(String baseURL, String relativeURL, String ChromeDriverPath) throws InterruptedException {

// driver.manage().window().setPosition(new Point(-2000, 0));
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
public BrowserEmulator(String baseURL, String relativeURL, String pathToChromeDriver) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", pathToChromeDriver);
driver = new ChromeDriver();
driver.get(
baseURL + relativeURL
);
Thread.sleep(10000);
}

public BrowserEmulator(String fullURL, String ChromeDriverPath) throws InterruptedException {
driver = Selenium.setUpChromeDriver(ChromeDriverPath);
// driver.manage().window().setPosition(new Point(-2000, 0));
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
public BrowserEmulator(String fullURL, String pathToChromeDriver) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", pathToChromeDriver);
driver = new ChromeDriver();
driver.get(
fullURL
);
Thread.sleep(10000);
}

public void waitPageLoad() {
new WebDriverWait(driver, 60).until(
webDriver -> ((JavascriptExecutor) webDriver)
.executeScript("return document.readyState").equals("complete"));
}

/**
Expand All @@ -61,10 +65,7 @@ public BrowserEmulator(String fullURL, String ChromeDriverPath) throws Interrupt
*/
public void clickEvent(String CSSSelector) throws InterruptedException {
WebElement element = driver.findElement(By.cssSelector(CSSSelector));
Actions actions = new Actions(driver);
Action action = actions.moveToElement(element).click().release().build();
action.perform();
Thread.sleep(3000L);
element.click();
}

/**
Expand Down

This file was deleted.

0 comments on commit 00c47d6

Please sign in to comment.