I want to scrape the following website http://condorbus.cl/ by GEB but this error appears
org.openqa.selenium.NoSuchElementException: Unable to locate element with ID: radio_solo_ida
this the code
def browser = params.browser
browser.drive {
go "http://condorbus.cl/"
waitFor(20) { $("div form#ventapasajes").verifyNotEmpty() }
// Find an element and define it
WebElement elementToClick = driver.findElement(By.id("radio_solo_ida"));
// Scroll the browser to the element's Y position
((JavascriptExecutor) driver).executeScript("window.scrollTo(
0,"+elementToClick.getLocation().y+")");
// Click the element
elementToClick.click();
I am not sure why you are getting the error I tried locating and clicking on the element with id='radio_solo_ida' and it worked using firefox driver.
That means the element with id='radio_solo_ida' is present and also uniquely identified by xpath=//*[@id='radio_solo_ida']
So the problem maybe related to a particular browser version or synchronization or combination of both I tried using following code for FIREFOX 31.0 and it works:
public class TestRadioButton {
public static void main(String args[])
{
WebDriver driver= new FirefoxDriver();
driver.get("http://condorbus.cl/");
WebElement elementToClick = driver.findElement(By.id("radio_solo_ida"));
// Scroll the browser to the element's Y position
((JavascriptExecutor)driver).executeScript("window.scrollTo(0,"+elementToClick.getLocation().y+")");
// Click the element
elementToClick.click();
}
}