Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium webdriver wait element and click

InternetExplorerDriver  driver = new InternetExplorerDriver();

driver.get("http://www.wiki-doctor.com");
WebElement element = (new WebDriverWait(driver, 10))
               .until(ExpectedConditions.elementToBeClickable(By.id("btnSearch")));
element.click();

it waits for the element btnSearch to be displayed and click on it, however, it doesn' t seems to do anything, do you have any idea why it happens ?

Thanks

like image 422
dtjmsy Avatar asked Mar 27 '26 07:03

dtjmsy


1 Answers

This adds United States as a locale, and then waits until a picture of the doctor is displayed.

driver.get("http://www.wiki-doctor.com");
//Enter united states into field
driver.findElement(By.id("field-findDoctor-town")).sendKeys("United States");
WebElement element = (new WebDriverWait(driver, 10))
               .until(ExpectedConditions.elementToBeClickable(By.id("btnSearch")));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);

WebDriverWait wait = new WebDriverWait(driver,10);
//Wait for picture of doctor
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#dvparcticianlist > div.row > div > div.listing-row > div.doc-photo-container")));
       System.out.println("Search Successful");
   }
like image 120
Reez0 Avatar answered Mar 30 '26 08:03

Reez0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!