0
 HtmlUnitDriver driver = new HtmlUnitDriver();
 driver.setJavascriptEnabled(true);
 String baseUrl = "http://www.biletix.com/search/TURKIYE/en#!city_sb:istanbul,date_sb:weekend";
 driver.get(baseUrl);
 WebElement myDynamicElement =
 new WebDriverWait(driver, 220).until(
 ExpectedConditions.presenceOfElementLocated(By.id("all_result")));
 System.out.println( myDynamicElement.getText());
 Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 220 seconds waiting for presence of element located by: By.id: all_result
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: '-PC', ip: '192.168.1.203', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_79'
Driver info: org.openqa.selenium.htmlunit.HtmlUnitDriver
 at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:80)
 at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:261)
 at Main.main(Main.java:167)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element with ID: all_result
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: '-PC', ip: '192.168.1.203', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_79'
Driver info: driver.version: HtmlUnitDriver
 at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementById(HtmlUnitDriver.java:1018)
 at org.openqa.selenium.By$ById.findElement(By.java:218)
 at org.openqa.selenium.htmlunit.HtmlUnitDriver5ドル.call(HtmlUnitDriver.java:1715)
 at org.openqa.selenium.htmlunit.HtmlUnitDriver5ドル.call(HtmlUnitDriver.java:1)
 at org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:1363)
 at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1711)
 at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:606)
 at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:911)
 at org.openqa.selenium.support.ui.ExpectedConditions.access0ドル(ExpectedConditions.java:909)
 at org.openqa.selenium.support.ui.ExpectedConditions6ドル.apply(ExpectedConditions.java:181)
 at org.openqa.selenium.support.ui.ExpectedConditions6ドル.apply(ExpectedConditions.java:1)
 at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:238)
 ... 1 more

It gives above errors.

But when i use firefox like that,no errors:

FirefoxDriver driver = new FirefoxDriver();
String baseUrl = "http://www.biletix.com/search/TURKIYE/en#!city_sb:istanbul,date_sb:weekend";
driver.get(baseUrl);
WebElement myDynamicElement =
 new WebDriverWait(driver, 50).until(
 ExpectedConditions.presenceOfElementLocated(By.id("all_result")));
System.out.println( myDynamicElement.getText());

For html driver, unworking code:

 HtmlUnitDriver driver = new HtmlUnitDriver();
 driver.setJavascriptEnabled(true);
String baseUrl = "http://www.biletix.com/search/TURKIYE/en#!city_sb:istanbul,date_sb:weekend";
 driver.get(baseUrl);
 WebElement myDynamicElement =
 new WebDriverWait(driver, 220).until(
ExpectedConditions.presenceOfElementLocated(By.id("all_result")));
 System.out.println( myDynamicElement.getText());

I also tried

 HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_38);

but same

Also did this

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
 capabilities.setBrowserName("Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0");
 capabilities.setVersion("24.0"); 
 capabilities.setJavascriptEnabled(true);
WebDriver driver = new HtmlUnitDriver(capabilities);

but still same.

ilm
3862 gold badges5 silver badges18 bronze badges
asked Nov 21, 2015 at 16:48

1 Answer 1

0

I solved.

As i wanted a headless browser, i tried to use phantomjs and i succeed.

File file = new File("lib/phantomjs-2.0.0-windows/bin/phantomjs.exe"); 
System.setProperty("phantomjs.binary.path", file.getAbsolutePath());
WebDriver driver = new PhantomJSDriver();
String baseUrl = "http://www.biletix.com/search/TURKIYE/en#!city_sb:istanbul,date_sb:weekend";
driver.get(baseUrl);

Because i dont want to use firefox driver and htmlunitdriver rhino is low for this, i tried phantom and it is really cool. Thanks everyone.

answered Nov 21, 2015 at 18:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.