第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

org.openqa.硒.無效選擇器例外: 無效的選擇器 語法錯誤:

org.openqa.硒.無效選擇器例外: 無效的選擇器 語法錯誤:

猛跑小豬 2022-09-28 16:14:34
我正在嘗試單擊以下HTML中的最后一個跨度元素<div class="rating rating-set js-ratingCalcSet" >  <div class="rating-stars js-writeReviewStars">     <span class="js-ratingIcon glyphicon glyphicon-star fh"></span>    <span class="js-ratingIcon glyphicon glyphicon-star lh"></span>     ...    <span class="js-ratingIcon glyphicon glyphicon-star fh"></span>    <span class="js-ratingIcon glyphicon glyphicon-star lh"></span>  </div></div>在Java中使用硒,具有以下代碼:driver.findElement(By.xpath("(//div[contains(@class, 'js-writeReviewStars')]//span)[last()]")).click(); 這將返回一個異常:org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression (//div[contains(@class, 'js-writeReviewStars')]//span)[last()] because of the following error:SyntaxError: Unexpected token }  ...*** Element info: {Using=xpath, value=(//div[contains(@class, 'js-writeReviewStars')]//span)[last()]}我已經(jīng)檢查了xpath表達(dá)式的有效性,它似乎是正確的(使用 https://www.freeformatter.com/xpath-tester.html),因?yàn)樗业搅四繕?biāo)元素。我嘗試過用括號將整個表達(dá)式括起來,但這不起作用。
查看完整描述

1 回答

?
慕運(yùn)維8079593

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超5個贊

你很接近。要識別標(biāo)記中的標(biāo)記,您需要從中刪除多余的  和  對last()<span><div>斷續(xù)器.

因此,您需要有效地改變:

driver.findElement(By.xpath("(//div[contains(@class, 'js-writeReviewStars')]//span)[last()]")).click();

如:

driver.findElement(By.xpath("//div[contains(@class, 'js-writeReviewStars')]//span[last()]")).click();



查看完整回答
反對 回復(fù) 2022-09-28
  • 1 回答
  • 0 關(guān)注
  • 86 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號