I have written a java program that utilizes Selenium to control Google Chrome. If I run the program on my machine, the program runs properly and at a reasonable speed. However, when I export this file to another machine (as a .jar or .exe), it still runs properly but is extremely slow. Specifically, it seems to take much longer to write in text boxes and click on buttons.
Throughout the program, I call this method to ensure that the text box/label will exist before an action occurs:
/**
* This function allows the driver to wait until the element is visible before interacting with it
* @param driver - The driver that is being used
* @param webElement - A string describing the xpath of the element to wait for
* @param seconds - The maximum number of seconds that the driver is willing to wait
* @return - The WebElement after it has appeared on the page
*/
public static WebElement waitForElementToBeVisible(WebDriver driver, String webElement, int seconds) {
try {
WebDriverWait wait = new WebDriverWait(driver, seconds);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(webElement)));
return element;
}
catch (TimeoutException e){
return null;
}
}
And, I call this method to ensure that the button is clickable before calling the action:
/**
* This function allows the driver to wait until the element is clickable before interacting with it
* @param driver - The driver that is being used
* @param webElement - A string describing the xpath of the element to wait for
* @param seconds - The maximum number of seconds that the driver is willing to wait
* @return - The WebElement after it has appeared on the page
*/
public static WebElement waitForElementToBeClickable(WebDriver driver, String webElement, int seconds) {
WebDriverWait wait = new WebDriverWait(driver, seconds);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(webElement)));
return element;
}
From my research, I attempted to fix the problem in a variety of ways. First, I attempted to adjust the Proxy settings through Google Chrome, but the settings were the same on both machines. Second, I tried to set the proxy settings programmatically but that also did not speed up the program. Finally, I tried to reduce the time that is passed in to the methods above. Unfortunately, that did not speed up the program either. Does anyone know how to have similar performance of Java Selenium programs on every machine?
Thank you in advance for any help that you are able to provide.