3
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

3
  • 1
    What browser are you using? When I run your code using chrome, I get an alert saying "Please insert address". Commented Nov 24, 2017 at 11:35
  • I am using Internet Explorer Commented Nov 24, 2017 at 12:21
  • String service = "C:\\ToolsQA\\IEDriverServer_x64_3.7.0\\IEDriverServer.exe"; System.setProperty("webdriver.ie.driver", service); InternetExplorerDriver driver = new InternetExplorerDriver(); Commented Nov 24, 2017 at 12:22

3 Answers 3

3

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");
   }
Sign up to request clarification or add additional context in comments.

2 Comments

hi, Reezo, a question regarding the argument[0], wha' s that ? where is this object coming from ? cheers
Check the definition from Selenium ExecuteScript page The arguments will be made available to the JavaScript via the "arguments" magic variable, as if the function were called via "Function.apply" and the returning value of executeScript is: Returns: One of Boolean, Long, String, List or WebElement. Or null. which means that returning object is a list and you can interact with by arguments[0] magic variable.
1

Once the page is loaded, first we need to wait for the intended WebElement i.e. the first Search Box to be clickable. Then we will send some text to both the Search Boxes and then invoke click() method on the Search Button as follows :

System.setProperty("webdriver.ie.driver", "C:\\Utility\\BrowserDrivers\\IEDriverServer.exe");
WebDriver  driver = new InternetExplorerDriver();
driver.get("http://www.wiki-doctor.com");
WebElement locality = (new WebDriverWait(driver, 5))
       .until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='field-findDoctor-town']")));
locality.sendKeys("Pune");
driver.findElement(By.xpath("//input[@id='speciality']")).sendKeys("Doctor");
driver.findElement(By.xpath("//button[@id='btnSearch']")).click();

3 Comments

I tried your code and still nothing happens, even the searchbox is not filled, it' s like the ids are never found
I think there is something to do with my internet explorer version and the download driver, as the codes works pretty well in chrome
Check out my updated Answer and let me know the status
-1
WebDriverWait wait =new WebDriverWait(driver, 90);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("xpath")));     
driver.findElement(By.xpath("xpath")).click();

1 Comment

Please make an effort to explain your answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.