I searched the forums for a *clear* answer to this question but wasn't
able to find one.
I have tried in Selenium 2.04 with both the FirefoxDriver and
ChromeDriver to click a link that looks like this
<form id="logout" name="logout" method="post" action="/beta/member/
browse.seam" enctype="application/x-www-form-urlencoded">
109<input type="hidden" name="logout" value="logout" />
110
111<script type="text/javascript" language="Javascript">function
dpf(f) {var adp = f.adp;if (adp != null) {for (var i = 0;i <
adp.length;i++) {f.removeChild(adp[i]);}}};function apf(f, pvp) {var
adp = new Array();f.adp = adp;var ps = pvp.split(',');for (var i =
0,ii = 0;i < ps.length;i++,ii++) {var p =
document.createElement("input");p.type = "hidden";
p.name =
ps[i];p.value = ps[i + 1];f.appendChild(p);adp[ii] = p;i +=
1;}};function jsfcljs(f, pvp, t) {apf(f, pvp);var ft = f.target;if (t)
{f.target = t;}f.submit();f.target = ft;dpf(f);};</script>
112<a href="#" onclick="if(typeof jsfcljs == 'function')
{jsfcljs(document.forms['logout'],'logout:j_id254,logout:j_id254','');}
return false">Sign Out</a><input type="hidden"
name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id5" /
>
113</form></li>
I have used the following locators
@FindBy(how = How.XPATH, using = "//a[@href='#']")
@FindBy(how = How.LINK_TEXT, using = "Sign Out")
In both cases, WebDriver clearly finds the element (because it passes)
and it apparently think the link is clicked, but I am not taken to the
expected page. Rather, I stay on the page.I'm guessing the JavaScript
doesn't automatically execute. So it appears I have to do something
to execute JavaScript, but I'm not sure exactly how to do this.
I tried to use the JavascriptExecutor, but clearly my understanding of
JavaScript is not extensive enough for me to figure this out easily
Can anyone give me a hand? Is there something I can set so just
clicking on this works? It worked in Selenium 1 (though it did give
an unexpected error)
Please help