Question

I am working on writing a story for a bdd framework which uses jbehave/selenium/webdriver and am having a problem where the test encounters an error while running the story but appears to be fine when running manually. I'm having a problem where javascript for the functionality I'm testing behaves slightly different when I'm running tests manually on firefox vs through selenium web driver on the same system/version of firefox and this difference is causing a js error.

I've debugged and basically the root of the problem appears to be that var request_XML_container = $('div_appendpoint_id'); returns something different when I'm running the test manually vs when I run through the bdd framework.

    var request_XML_container = $('div_appendpoint_id');
    request_XML_container.innerHTML = encoded_xml_from_request;
    var pos = method_to_get_position('id_of_place_div_should_be_appended_to');

    // JS exception is thrown saying that style is not defined **ONLY** 
    // when running through web driver.  Running test manually on 
    // same system and same browser works fine.
    request_XML_container.style.left = (pos[0] - 300) + 'px';
    request_XML_container.style.top = (pos[1] + 25) + 'px';
    request_XML_container.style.display = "block";

Why this would work fine when running manually that var request_XML_container = $('div_appendpoint_id'); would return an item with style defined, but when running through webdriver that the style attribute of the element would not be defined?

UPDATE: I had originally thought that this was updating an iframe, but I read the markup wrong and the iframe I saw is a sibling - not a parent - of the element where the response is being appended to. I'm trying to simply append the response to a div. To be honest, this only makes things more confusing as grabbing a div by id should be pretty straight forward and I'm now sure why webdriver would be producing a different return element in this situation.

UPDATE 2: Steps to reproduce and information about the system I'm on:

  1. Use webdriver to navigate to this url: http://fiddle.jshell.net/C3VB5/11/show/
  2. Have webdriver click the button. It should not work
  3. Run your test again, but pause put a breakpoint at your code to click the driver
  4. Click the button on the browser that webdriver opened. It should not work
  5. Refresh the browser page on the browser that webdriver opened. Now, it should work.
  6. System details:
    • OS : OS X 10.8.5 (12F37)
    • IDE : Eclipse Kepler: Build id: 20130614-0229
    • Browser (used manually and by webdriver) : Firefox 23.0.1
    • Selenium version: 2.35.0

UPDATE 3: I have provided this maven project on github to aid in reproducing: https://github.com/dkwestbr/WebdriverBug/tree/master/Webdriver

Synopsis/tl:dr; Basically, in certain situations it appears as though webdriver is overwriting the '$()' javascript method with a method that does not return an HTMLElement with innerHTML or style defined (among other things). This post details the issue and how to reproduce.

I have opened this ticket to track the issue: https://code.google.com/p/selenium/issues/detail?id=6287&thanks=6287&ts=1379519170

Was it helpful?

Solution

I have confirmed that this is a bug with the Thucydides framework (understandable since they still aren't at a 1.0 release).

Issue can be tracked here: https://java.net/jira/browse/THUCYDIDES-203

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top