Skip to content

Instantly share code, notes, and snippets.

@areyoutoo
Last active December 21, 2015 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save areyoutoo/6242665 to your computer and use it in GitHub Desktop.
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
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.
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"]');
}
<html>
<body>
<iframe name="if" id="if" src="iframe.html" />
</body>
</html>
<html>
<head>
<base target="_parent" />
</head>
<body>
<a id="anchor" href="success.html">Click this link</a>
</body>
</html>
<html>
<body>
<h1>It worked!</h1>
</body>
</html>
@areyoutoo
Copy link
Author

Reported as Selenium 6111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment