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

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

我如何使用硒等待 magento 購物車頁面上的預期值

我如何使用硒等待 magento 購物車頁面上的預期值

拉風的咖菲貓 2023-03-02 15:18:18
在觸發下一個點擊事件之前,我嘗試使用 selenium webdriver 等待購物車頁面上的計算總計。但我有一個例外。我可以等待的頁面上沒有其他元素。我認為為有經驗的開發人員找到解決方案真的很容易,但我不是那個人。我使用這個等待命令:wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".grand.totals .price"), "35,75 €"));`這是我嘗試選擇元素的源代碼片段。<tr class="grand totals">    <th class="mark" scope="row">        <strong data-bind="i18n: title">Bestellsumme</strong>    </th>    <td data-bind="attr: {'data-th': title}" class="amount" data-th="Bestellsumme">        <strong><span class="price" data-bind="text: getValue()">35,75&nbsp;€</span></strong>    </td></tr>這是我得到的例外。org.openqa.selenium.ElementNotVisibleException:元素不可交互(會話信息:chrome=75.0.3770.100)(驅動程序信息:chromedriver=74.0.3729.6(255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729),@=平臺NT 10.0.17134 x86_64)(警告:服務器未提供任何堆棧跟蹤信息)命令持續時間或超時:0 毫秒構建信息:版本:'3.141.59',修訂:'e82be7d358',時間:'2018-11-14T08 :17:03' 系統信息:主機:'MARCEL-THINK',ip:'10.110.12.3',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java .version: '11.0.3' 驅動程序信息:org.openqa.selenium.chrome.ChromeDriver
查看完整描述

1 回答

?
料青山看我應如是

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

看來你很親密。文本35,75 €在中間包含一個空格字符,并且位于<span>標記內。因此,您可以使用以下任一定位器策略

  • cssSelector:

    new WebDriverWait(driver, 20).until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("tr.grand.totals td.amount>strong>span.price"), "35,75"));
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.textToBePresentInElementLocated(By.xpath("//tr[@class='grand totals']//td[@class='amount']/strong/span[@class='price']"), "35,75"));



查看完整回答
反對 回復 2023-03-02
  • 1 回答
  • 0 關注
  • 92 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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