我可以通過driver.findElement()
函數實現所有元素。 樹元素是使用dhtmlx庫創建的,當我嘗試接觸它們時,我得到NoSuchElementException。Selenium dhtmlxtree Chrome中的NoSuchElementException
我試圖通過ID,xpath,類,文本等,但他們都沒有爲我工作。我也嘗試了隱式等待和Thread.sleep()
方法,但結果是一樣的。
> <tr> <td class="standartTreeImage"> <img border="0" align="absmiddle"
> style="padding: 0px; margin: 0px; width: 18px; height: 18px;"
> src="http://marduk:5543/atlas/themes/third_party/dhtmlx/dhtmlxTree/codebase/imgs/vse_datasources/plus3.gif">
> </td> <td width="20px" style="display: none;"> <img align="absmiddle"
> src="http://marduk:5543/atlas/themes/third_party/dhtmlx/dhtmlxTree/codebase/imgs/vse_datasources/iconUncheckAll.gif"
> style="width: 16px; height: 16px;"> </td> <td
> class="standartTreeImage" style="width: 18px;"> <img border="0"
> align="absmiddle" style="padding: 0px; margin: 0px; width: 18px;
> height: 18px;"
> src="http://marduk:5543/atlas/themes/third_party/dhtmlx/dhtmlxTree/codebase/imgs/vse_datasources/folderClosed.gif">
> </td> <td class="standartTreeRow" nowrap="" style="width: 100%;
> font-size: 10pt; cursor: pointer;"> <span class="standartTreeRow"
> style="padding-left: 5px; padding-right: 5px;">hr-istanbul [15]</span>
> </td> </tr>
例如其中一個是這樣的:我需要點擊第一td
。只有定位器是圖像,但我無法訪問元素.. NoSuchElementException。
element = driver.findElement(By.xpath("//img[contains(@src,'http://marduk:5543/atlas/themes/third_party/dhtmlx/dhtmlxTree/codebase/imgs/vse_datasources/plus3.gif')]"));
也試圖達到最後一列元素它沒有工作。
element = driver.findElement(By.xpath("//*[contains(text(), 'hr-istanbul [15]')]"));
能有比相同ID的一個元素嗎? – user2761286
分享你的HTML和Java代碼 – Ab123
其中一些甚至不包含任何ID,但他們有獨特的文本字段等來找到它們。我不能分享,因爲我提到,將嘗試分享其中的一部分 –