0

I looked around and couldn't find an specific answer that helped me figure out what's happening in my code.

I'm running a selenium webdriver test using the htmlunitdriver . I'm just uploading a picture on photobucket for learning purposes. I've used FirefoxDriver and it worked perfectly fine. Then I tried to use htmlunitdriver and my IDE says the code is working (I just changed FirefoxDriver for htmlunitdriver) but whenever I check my picture album I don't see the picture. My first guess is that the headless browser is not waiting for the picture to upload and so it just leaves, so I added some ugly sleeps to check onto that and still doesn't work!

Here's the code

driver.get("http://s394.photobucket.com/upload/links");
    Thread.sleep(3000);
    driver.findElement(By.id("urlInput")).sendKeys("photo_link");
    driver.findElement(By.id("uploadBtn")).click();
    Thread.sleep(3000);
    String text = driver.findElement(By.className("progressCount")).getText();
    driver.findElement(By.id("goalbum")).click();
    driver.close();

The getText() is used on a HTML element that looks like this.

<div class="progressCount" style="width: 711px;">100%</div>

It's a loading bar. The point for this is to make webdriver web wait until the bar announces that it is full to proceed and close the driver.

Whenever I try to use getText, Intellij throws a series of warnings and errors from the DefaultCssErrorHandler related to "style rule" though and the string remains empty.

1 Answers1

0

You can also try following :

driver.findElement(By.cssSelector("div.progressCount")).getText();

Aru
  • 134
  • 4