Last active
December 21, 2015 03:29
-
-
Save areyoutoo/6242665 to your computer and use it in GitHub Desktop.
Reduced test case for an XPath locator problem when using Selenium RC 2.34.0 with Firefox 23.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Quick explanation of the problem: | |
This works fine: | |
open(...) | |
selectFrame(...) | |
click(css=#anchor) | |
This does not: | |
open(...) | |
selectFrame(...) | |
click(xpath=//a[@id="anchor"]) | |
This gist is a reduced test case involving three pages: | |
iframe-index.html | |
iframe.html | |
success.html | |
We also include demo.pl to issue commands to Selenium RC. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use WWW::Selenium; | |
#give ourselves a browser | |
my $sel = WWW::Selenium->new( | |
browser => '*firefox', | |
browser_url => 'http://localhost', | |
host => 'localhost', | |
port => 4444, | |
); | |
#load page, select frame, everything's good so far | |
$sel->start; | |
$sel->open('http://localhost/iframe-index.html'); | |
$sel->select_frame('if'); | |
#here's where we hit a snag, if we use the xpath locator | |
my $USE_CSS = 1; | |
if ($USE_CSS) | |
{ | |
# works fine with CSS locator | |
$sel->click('css=#anchor'); | |
} | |
else | |
{ | |
# Firefox 22.0 works fine | |
# Firefox 23.0 gives ERROR: Invalid xpath [2]: //a[@id="anchor"] | |
$sel->click('xpath=//a[@id="anchor"]'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<iframe name="if" id="if" src="iframe.html" /> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<base target="_parent" /> | |
</head> | |
<body> | |
<a id="anchor" href="success.html">Click this link</a> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<h1>It worked!</h1> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reported as Selenium 6111