首页 > 解决方案 > 我如何使用硒等待 magento 购物车页面上的预期值

问题描述

在触发下一个点击事件之前,我尝试使用 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;€&lt;/span></strong>
    </td>
</tr>

这是我得到的例外。

org.openqa.selenium.ElementNotVisibleException:元素不可交互(会话信息:chrome=75.0.3770.100)(驱动程序信息:chromedriver=74.0.3729.6(255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),平台=Windows 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

标签: javaseleniumxpathcss-selectorswebdriverwait

解决方案



推荐阅读