簡體   English   中英

硒無法找到框架內的字段

[英]Selenium Can't Locate Field Inside of Frame

我正在嘗試在框架內定位對象,但是Selenium一直在返回它試圖定位元素超時的返回信息。

以下是相關的代碼信息:

框架ID為tasks-splash-content 我正在使用此方法調用SeleniumCommands.myDriver.switchTo().frame("tasks-splash-content");切換到它SeleniumCommands.myDriver.switchTo().frame("tasks-splash-content");

我嘗試查找並發送密鑰的字段的ID為txt_dateofbirth ,xpath為html/body/table/tbody/tr/td/table/tbody/tr[1]/td/div/table/tbody/tr/td/table/tbody/tr[4]/td[1]/input[1] 到目前為止,這兩種選擇方法都不適用於我。

這是我的方法的函數體,它通過xpath來查找元素wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath)));

因此,依次地,我切換到框架,等待該字段可見,然后嘗試向其發送一些值。 有誰知道這可能導致它不適用於我?

框架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>

您需要在其中搜索嵌套的iframe

SeleniumCommands.myDriver.switchTo().frame("tasks-splash-content");
SeleniumCommands.myDriver.switchTo().frame(0);  // switch to the very first iframe

另外,請注意,您提供的XPath表達式不太可靠,請嘗試依賴id,面向數據的類和屬性或有意義的容器或鄰居。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM