1

I try to wait with selenium webdriver for the calculated grand totals on the cart page before I trigger the next click event. But I got a exception. I have no other element on the page that I could wait for. I think it's really easy to find a solution for expierenced developers but I'm not the one.

I use this wait command:

wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".grand.totals .price"), "35,75 €"));`

This is the source code snippet who I tries to select the element.

<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>

This is the exception did I got.

org.openqa.selenium.ElementNotVisibleException: element not interactable (Session info: chrome=75.0.3770.100) (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'MARCEL-THINK', ip: '10.110.12.3', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.3' Driver info: org.openqa.selenium.chrome.ChromeDriver

Roberto Pegoraro
  • 1,313
  • 2
  • 16
  • 31
Siggi
  • 13
  • 2
  • According to exception any other element overplayed the target element, is this element present after any progress bar? – Saurabh Gaur Jul 03 '19 at 11:35

1 Answers1

0

Seems you were close. The text 35,75 € includes a space character in between and is within a <span> tag. So you can use either of the following Locator Strategies:

  • 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"));
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352