Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have problem with PHPUnit_Selenium in Opera. If I have clicked on element in my test code, the page will not load. In other browsers such as Firefox, IE, Chrome and Safari, it works correctly.

Code:

$browser->clickAndWait(link);

It's next steps from SELENIUM REMOTE CONTROL:

click(link)
waitForPageToLoad(120000)

After timeout, if I click on link in browser the page is reloaded.

I have Selenium RC v. 2.31.0 and Opera version 12.41, but i test also on Opera 11.50.

Do you have any idea what is wrong?

share|improve this question
did you search the selenium bug tracker? – cweiske Mar 11 at 12:12
Yes, i searched on selenium bug tracker, but i didn't find to resolve my problem. – Szymon Mar 11 at 15:28
Is it possible that the link is bound to a Javascript event that isn't being handled properly by Opera? Can you perform the link click by hand on Opera? – Dan Chan Apr 1 at 19:58
@DanChan, yes, I can click this link in test mode Opera, and all working normal in opera, when I test without selenium. – Szymon Apr 3 at 10:00
How are you targeting the link? css or xpath? the check if the selector syntax is supported in Opera – Andre Apr 4 at 10:58
show 1 more comment

1 Answer

There wasn't enough information in the original post to suggest a definitive solution, but tying in with the comment @Andre provided, the "sanitizing" browsers do, and in turn provide in functions such as "Copy xPath" can be very misleading, and lead to many problems during testing, depending on the structure of the xPath.

For example:

<html>
    <head></head>
    <body>
        <div>
            <table>
                <tr>
                    <td>test</td>
                </tr>
                <tr>
                    <td>value</td>
                </tr>
            </table>
        </div>
    </body>
</html>

While the above code is very minimal, browsers will report the xPath of test as one of the following:

  • /html/body/div/table/tr/td ( which in many cases will return you both test and value )
  • /html/body/div/table/tr[1]/td[1] ( a more precise match to just test )
  • /html/body/div/table/tbody/tr/td ( notice the added tbody )

And so on. Obviously, you don't run into this problem with a more unique identifier available ( IE an id -> //*[@id="someElement"] ), but in many projects we've taken over, where the unit tests were originally only done on one browser, we've seen errors similar to the one reported, and it turned out the "sanitizing" browsers do create one of two problems:

  • The path was retrieved on a browser that "sanitized", and then run on a browser that wouldn't and couldn't find the element.
  • The path was retrieved on a browser that wasn't "sanitized", and then run on a browser that does sanitize.

Both issues resulting in a non-match.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.