0

When automating our tests for web (C#, Selenium WebDriver 2.53.0, PhantomJS 2.1.1), I cannot locate some of the elements. When I looked to the innerHTML of the parent element, I see, that html generated by PhantomJS is 1) incomplete and 2) contains special characters - see excerpt.

<div class=\"buttons\">
  <table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" cl=""
ass=\"button_line\">
    \r\n\t\t\t\t\t\t\t<tbody>
      <tr>
        \r\n\t\t\t\t\t\t\t\t<td></td>\r\n\t\t\t\t\t\t\t\t<td>&nbsp;</td>\r\n\t\t\t\t\t\t\t\t<td></td>\r\n\t\t\t\t\t\t\t\t<td>&nbsp;</td>\r\n\t\t\t\t\t\t\t\t<td></td>\r\n\t\t\t\t\t\t\t\t<td>&nbsp;</td>\r\n\t\t\t\t\t\t\t\t<td></td>\r\n\t\t\t\t\t\t\t\t<td>&nbsp;</td>\r\n\t\t\t\t\t\t\t\t<td width=\"100%\">&nbsp;</td>\r\n\t\t\t\t\t\t\t
      </tr>\r\n\t\t\t\t\t\t
    </tbody>
  </table>\r\n\t\t\t\t\t\t
</div>"

With chrome the html code is more complex - e.g. contains more child elements also for this table which is in the excerpt. Is PhantomJS too fast, so some of the code did not get the chance to be updated? (How to force this?) And why are there those characters? (How can I fix this?)

Update 1: As suggested, this question might be answered by the How to wait for element to load in selenium webdriver?, however I think this is different issue. As I suggested in one of the comments, I'm already using ImplicitWait which works fine for all other browsers. I even tried Explicit wait and use it for parts problematic in PhantomJS, but to no avail :(.

Maybe to add more info: the problematic tests have something to do with javascript and refresh of the page in PhantomJS.

Usual scenario is like selecting row in some Overview table and then checking for values (fields) in details section (which was empty until then - no fields displayed).

Community
  • 1
  • 1
gurbi
  • 163
  • 2
  • 14
  • These "special characters" are likely shown because of the way you're retrieving or printing the page source string. – Artjom B. Apr 01 '16 at 12:42
  • Possible duplicate of [How to wait for element to load in selenium webdriver?](http://stackoverflow.com/questions/25374382/how-to-wait-for-element-to-load-in-selenium-webdriver) – Artjom B. Apr 01 '16 at 12:43
  • Well, when it comes to printing page source, it is by usual element.GetAttribute("innerHTML"). But you are right - those are there even when acquired for different browsers (interesting that I haven't realised it until now ...) – gurbi Apr 01 '16 at 13:43
  • I'm not sure it is really duplicate of [How to wait for element to load in selenium webdriver?](http://stackoverflow.com/questions/25374382/how-to-wait-for-element-to-load-in-selenium-webdriver). I'm using ImplicitWait as well as explicit wait for some elements, but still, the problem is, that the page is still incomplete. Might it have something to do with some JavaScript actions which are performed prio to searching for those elements? – gurbi Apr 01 '16 at 13:51

0 Answers0