框架的概念正在我负责测试的网站上使用。但是,这些框架不使用框架标签,例如一个由GET/POST填充的div。 Selenium无法访问框架内部的元素(ElementNotVisibleException),因为它必须先切换到框架。但是,我无法切换到框架,因为它在技术上不是Selenium眼中的框架。如何在不操作DOM的情况下访问框架的内容? (测试点是我们测试最终用户是什么,不要改变它)。所以,我不能使用JavaScript执行程序。我曾尝试使用动作构建来单击元素/移动到元素,但它会返回错误。如何使用Selenium Webdriver访问不带框架标签的框架元素?
编辑:
这里是我试图访问的html的基本形式。我无法使用硒访问el1
中的任何元素。我需要为el6
选择一个选项。
<div id="el1" style="width: 960px; height: 230px; margin-bottom: 6px;">
<div style="width: 955px;padding: 5px 0px 0px 5px;">
<span>Text Here</span>
<form id="el2" action="pageName.jsp?action=blah" method="POST" style="height: 300px;" name="el2">
<div id="el3" style="width: 600px; margin: 20px 0px 0px 60px;">
<div id="el4" style="height: 20px;">
<div id="el5" style="height: 20px; padding-left: 40px;">
<div style="width: 400px;">
<span style="font-weight: bold;">More Text Here</span>
</div>
<div style="width: 400px;">
<select id="el6" onchange="javascriptfunction(this)" name="el6" style="width: 400px;">
<option selected="selected" value="">A Select Box Option</option>
<option value="NumberHere">More Options Populated By JSP</option>
</select>
</div>
</div>
</div>
</div>
<!--Some Unnecessary content here-->
</form>
</div>
</div>
这里是el6
的风格计算。我试图用WebDriver手动调整高度,试图摆脱ElementNotVisibleException。这没有奏效。
font-family MS Shell Dlg
body Helvetica,Arial,Sans-Serif
div Arial,Helvetica,Geneva,sans-serif
body Arial,Helvetica,Geneva,sans-serif
font-size 13.3333px
div 14px
body 13px
color rgb(0, 0, 0)
#container #333
text-align start
#wrapper left
.bodyStyle center
width 400px
margin-top 0px
margin-right 0px
margin-bottom 0px
margin-left 0px
padding-top 0px
padding-right 0px
padding-bottom 0px
padding-left 0px
如果它在技术上是没有''
这不是一个等待问题,或者我没有正确地等待。我尝试过许多形式的等待,但都是暂停或不解决问题。 – user3735633
html中的元素有'action =“page.jsp?action = foo”'和'method =“POST”'。所以我的猜测是,POST行为正在持续发生,阻止硒“看到”元素。尽管我可能完全错误。 – user3735633