Reputation: 468
I am trying to locate an object inside of a frame, but Selenium keeps returning that it timed out trying to locate the element.
Here is the relevant code information:
The frame ID is tasks-splash-content
. I am switching to it with this method call SeleniumCommands.myDriver.switchTo().frame("tasks-splash-content");
The field I am trying to locate and send keys to has an id of txt_dateofbirth
and xpath of html/body/table/tbody/tr/td/table/tbody/tr[1]/td/div/table/tbody/tr/td/table/tbody/tr[4]/td[1]/input[1]
. So far, both selection methods have not worked for me.
Here is the function body of my method that finds an element by xpath wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath)));
So, sequentially, I am switching to the frame, waiting until the field is visible, and then trying to send it some values. Does anyone know what might be causing this to not work for me?
Frame HTML:
<div id="tasks-splash-window" class="ui-dialog-content ui-widget-content" style="width: auto; min-height: 0px; height: 638px; padding: 0px;" scrolltop="0" scrollleft="0">
<iframe id="tasks-splash-content" scrolling="no" frameborder="0" src="https://qa3.jobappdemo.com/apply/c_tca/l_en/applied/OpenForms.cfm?dr=i9&hp=1204988&fid=401">
<html>
<head></head>
<body>
<iframe width="890" height="635" frameborder="0" src="https://qa3.jobappdemo.com/jobapp/get_appl_i9.cfm?hired_profile_id=1204988&hired_id=1204930&i9_id=902486&lang=en&new=1&rnd=327">
</body>
</html>
</iframe>
</div>
</div>
Upvotes: 1
Views: 124
Reputation: 473853
There is a nested iframe
you need to search in:
SeleniumCommands.myDriver.switchTo().frame("tasks-splash-content");
SeleniumCommands.myDriver.switchTo().frame(0); // switch to the very first iframe
Also, note that the XPath expression you've presented is not quite reliable, try to rely on ids, data-oriented classes and attributes, or meaningful containers or neighbors.
Upvotes: 1