亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

硒 | NamespaceError:無法在“文檔”上執行“評估” | 包含不可解析的命名空間

硒 | NamespaceError:無法在“文檔”上執行“評估” | 包含不可解析的命名空間

一只斗牛犬 2022-11-30 14:28:34
我可以使用瀏覽器的開發人員工具檢查元素,如下所示:使用 FireFox 檢查元素:/html/body/div[1]/div/div[8]/form/div[2]/spring:eval/table/tbody/tr[2]/td[5]使用 Chrome 檢查相同的元素,如下所示://*[@id="searchVO"]/div[2]/spring:eval/table/tbody/tr[2]/td[5]但是,當我嘗試在腳本中使用這些 XPath 中的任何一個時,執行失敗并顯示以下堆棧跟蹤:WebElement formElement = wd.findElement(By.xpath("//*[@id=\"searchVO\"]/div[2]/spring:eval/table/tbody/tr[2]/td[5]"));或者WebElement formElement = wd.findElement(By.xpath("/html/body/div[1]/div/div[8]/form/div[2]/spring:eval/table/tbody/tr[2]/td[5]"));堆棧跟蹤:org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression //*[@id="searchVO"]/div[2]/spring:eval/table/tbody/tr[2]/td[5] because of the following error:NamespaceError: Failed to execute 'evaluate' on 'Document': The string '//*[@id="searchVO"]/div[2]/spring:eval/table/tbody/tr[2]/td[5]' contains unresolvable namespaces.………*** Element info: {Using=xpath, value=//*[@id="searchVO"]/div[2]/spring:eval/table/tbody/tr[2]/td[5]}    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)    at java.lang.reflect.Constructor.newInstance(Unknown Source)    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)我也確認網頁上沒有Frames;然而,上面的元素存在于一個表單中——下面給出了這個元素的片段——我試圖找到下面的狀態“Operative”或“Stopped”——上面的 Xpath 屬于這個狀態字段。在進行此搜索后,如果狀態為“Operative”,則我需要單擊 Product1。
查看完整描述

2 回答

?
慕森卡

TA貢獻1806條經驗 獲得超8個贊

這是操作的 xpath。

WebElement formElement = wd.findElement(By.xpath("//div[@id='nc-bd']/following-sibling::div[1]//table//tr[2]//td[5]"));

和 xpath 停止。

WebElement formElement = wd.findElement(By.xpath("//div[@id='nc-bd']/following-sibling::div[1]//table//tr[3]//td[5]"));


查看完整回答
反對 回復 2022-11-30
?
Helenr

TA貢獻1780條經驗 獲得超4個贊

這是將標識所有產品的 xpath Operative。

//form[@id='searchVO']//table//tr[td[normalize-space(.)='Operative']]/td[count(./ancestor::table//tr[1]/th[normalize-space(.)='Product'])+1]



查看完整回答
反對 回復 2022-11-30
  • 2 回答
  • 0 關注
  • 159 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號