gpt4 book ai didi

javascript - Selenium Web 驱动程序 - 找不到表单字段

转载 作者:行者123 更新时间:2023-11-28 04:19:31 25 4
gpt4 key购买 nike

尝试打开网页并填写表单。我能够成功打开父表单并进行身份验证,然后单击我要填写的表单。

进入此表单后,我尝试选择字段 (PF_5),Eclipse 告诉我该元素不可见。

网站的相关代码在这里。

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>RV Roster Form Version 205.0</title>
<style id="DateInputStyle" type="text/css"></style>
</head>
<link type="text/css" rel="stylesheet" href="/PresentationServer/Content/css/Common.css?4.5.3.5" />
<body>
<div id="pf_form" class="pf_formcontainer">
<form id="PF_1" class="form formBoxShadow" style="height:1600px;width:1800px;display:none;behavior: url('http://app.perfectforms.com/pie.htc');">
<div Id="PF_4Container" class="PageContainer" class="PageContainer" style="left:0px;top:0px;z-index:0;position:absolute">
<div tabindex="" title="" id="PF_4" name="PF_4" class=" page " style="width:1800px;height:1600px;background-color:#ffffff;">
<input id="PF_5" name="PF_5" type="text" MaxLength="99" value="" class=" textinput " onclick="return false;"

我看到 PF_5 是我想要选择的字段,因此我使用代码等待并选择它:

WebDriverWait wait = (new WebDriverWait(driver, 30));
WebElement input =
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("PF_5")));

如果我尝试向其发送 key ,则会收到该元素不可见的错误。

测试时,浏览器选项卡如预期一样位于前台,但我不能 100% 确定浏览器选项卡就是正在搜索该元素的选项卡。

抱歉这么迟钝,但我已经走进了死胡同,需要一些指导。

该表格可通过以下链接公开访问:

http://app.perfectforms.com/PresentationServer/Form.aspx/Play/FdjigAcE?f=FdjigAcE

最佳答案

好吧,看来脚本没有看到新选项卡,即使它在脚本运行时位于前面。我必须使用下面的代码来切换:'

String oldTab = driver.getWindowHandle();
driver.switchTo().frame("MTAzNzg1");
driver.findElement(By.id("PF_51")).click();

ArrayList<String> newTab = new ArrayList<String>
(driver.getWindowHandles());
newTab.remove(oldTab);
// change focus to new tab
driver.switchTo().window(newTab.get(0));

感谢所有帮助我找到这个的人!

关于javascript - Selenium Web 驱动程序 - 找不到表单字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45555770/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com