我是自動化界的新手。我自動化了我們公司網站上的一個頁面。 在腳本編寫過程中,我遇到以下情況:在檢測到一個標籤文本(用天藍色着色)時,我的代碼寫爲錯誤 '元素當前不可見,因此可能不與'互動,但標籤文本正確可見且可點擊。元素不可見
我嘗試所有的方法來找到這個標籤元素,但仍然是錯誤。所以我假設由於標籤文本顏色我的webdriver沒有檢測到這個標籤並記錄這個錯誤。
現在我關心的是。是否有可能由於標籤文本中使用的顏色wedriver沒有將標籤視爲可見。
請提供建議。
由於提前
添加代碼和HTML
Public WebElement GetDataSourceListByID(List<WebElement> Tables){
WebElement lstSearchFields;
WebElement fieldTable = null;
WebElement weTemp = null;
String tDataSourceId = null;
Actions Visible;
for(WebElement we : Tables){
List<WebElement> x = we.findElements(By.xpath("//*/div[contains(@id, 'treeview')]"));
for (WebElement c : x){
System.out.println("____________"+c.getAttribute("id"));
c.findElement(By.xpath("//*/span[contains(text(), 'Manage Stores')]")).click();
}
}
return fieldTable;
}
<div class="x-grid-item-container" style="width: 260px;">
<table id="treeview-1165-record-310" data-boundview="treeview-1165" data-recordid="310" data-recordindex="0" class="x-grid-item x-grid-item-selected" style=";width:0" cellpadding="0" cellspacing="0">
<tbody>
<tr class=" x-grid-row" data-qtip="" data-qtitle="">
<td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-plus x-tree-expander" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-parent edge-store-png"><span class="x-tree-node-text ">Stores</span></div>
</td>
<td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 refreshIcon" data-qtip="Refresh"></div>
</td>
</tr>
</tbody>
</table>
<table id="treeview-1165-record-311" data-boundview="treeview-1165" data-recordid="311" data-recordindex="1" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0">
<tbody>
<tr class="dvp-tree-node-disabled x-grid-tree-node-expanded x-grid-row" data-qtip="" data-qtitle="">
<td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-plus x-tree-expander" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-parent edge-workfolder-png"><span class="x-tree-node-text ">Search Folders</span></div>
</td>
<td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div>
</td>
</tr>
</tbody>
</table>
<table id="treeview-1165-record-318" data-boundview="treeview-1165" data-recordid="318" data-recordindex="2" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0">
<tbody>
<tr class="dvp-tree-node-disabled x-grid-row" data-qtip="M_test" data-qtitle="">
<td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-line" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-plus x-tree-expander" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-parent edge-workfolder-png"><span class="x-tree-node-text ">M_test</span></div>
</td>
<td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div>
</td>
</tr>
</tbody>
</table>
<table id="treeview-1165-record-319" data-boundview="treeview-1165" data-recordid="319" data-recordindex="3" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0">
<tbody>
<tr class="x-grid-tree-node-leaf x-grid-row" data-qtip="Darshan (3)" data-qtitle="">
<td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-line" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-end" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-leaf edge-searchfolder-png"><span class="x-tree-node-text ">Darshan (3)</span></div>
</td>
<td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div>
</td>
</tr>
</tbody>
</table>
<table id="treeview-1165-record-312" data-boundview="treeview-1165" data-recordid="312" data-recordindex="4" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0">
<tbody>
<tr class="dvp-tree-node-disabled x-grid-tree-node-expanded x-grid-row" data-qtip="" data-qtitle="">
<td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 edgeThemeColor x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-end-plus x-tree-expander" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-parent edge-setting"><span class="x-tree-node-text ">Manage Data Source</span></div>
</td>
<td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div>
</td>
</tr>
</tbody>
</table>
<table id="treeview-1165-record-322" data-boundview="treeview-1165" data-recordid="322" data-recordindex="5" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0">
<tbody>
<tr class="x-grid-tree-node-leaf x-grid-row" data-qtip="" data-qtitle="">
<td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 edgeThemeColor x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-empty" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-leaf edge-store-png"><span class="x-tree-node-text ">Manage Stores</span></div>
</td>
<td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div>
</td>
</tr>
</tbody>
</table>
<table id="treeview-1165-record-323" data-boundview="treeview-1165" data-recordid="323" data-recordindex="6" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0">
<tbody>
<tr class="x-grid-tree-node-leaf x-grid-row" data-qtip="" data-qtitle="">
<td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 edgeThemeColor x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-empty" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-leaf edge-connector-png"><span class="x-tree-node-text ">Manage Connectors</span></div>
</td>
<td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div>
</td>
</tr>
</tbody>
</table>
<table id="treeview-1165-record-324" data-boundview="treeview-1165" data-recordid="324" data-recordindex="7" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0">
<tbody>
<tr class="x-grid-tree-node-leaf x-grid-row" data-qtip="" data-qtitle="">
<td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 edgeThemeColor x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-empty" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-end" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-leaf edge-rule-png"><span class="x-tree-node-text ">Manage Rules</span></div>
</td>
<td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164">
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div>
</td>
</tr>
</tbody>
</table>
你可以分享硒代碼和HTML代碼嗎? –
請提供html格式的代碼,而不是圖片。我看不到任何'