尽管页面上有ID,元素始终返回null

时间:2019-12-13 10:37:47

标签: c# selenium getelementbyid

<div id="parent">
<div id="content-wrap">
<div id="content" class="clearfix">                
<!-- 2019.1.215.45 -->
<div id="content-main-admin">
<div class="clearfix">
<div class="clearfix">
<div class="content-right">
<h1>Working Shift Manager
</h1>
<p>
Please find below all of your working shifts for administration.
</p>
</div>
</div>
<div class="clearfix">
<div class="content-right">
<div id="ctl00_cphContent_litAdminButtons" class="admin-buttons clearfix" 
style="margin: 0 0 20px 0">
<a href="working-shift-admin.aspx" class="button add" id="btnAdd" 
onclick="doSpinnerStart()">
Add New</a>

无法单击id元素btnAdd

public IWebElement AddNewButton { get { return FindByID("btnAdd"); } 
尝试从html读取

Element时,其返回为null,如果代码匹配,则我的代码将上面的值与html中的值进行比较,然后单击添加按钮。在这种情况下,将返回null且未单击按钮

0 个答案:

没有答案