0

https://www.dell.com/en-us/cart?cs=19&~ck=mn

If we don't have active cart item then search for "Laptops " in the search bar and then Add one cart item to it .Click on " Go to Cart" now it will land on cart page . Where the checkout button will be Listed under "Cart Summary". I want you to locate that Checkout button. Kindly help me in locating it.

When I tried locating with below Xpath it works in ChromSearch Tab but when I placed in the C# code and try it throws an exception.

(//*[text()='Checkout'])[1]

or

(//button[@ng-class='continueDellMetricsClass'][text()='Checkout'])[1]

Kindly share me the locator to locate the Checkout button in cart using C#

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

The desired element is an Angular element so you have to induce WebDriverWait for the desired ElementToBeClickable and you can use either of the following Locator Strategies as solutions:

  • CssSelector:

    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("aside.visible-md.visible-lg button.continueButton"))).Click();
    
  • XPath:

    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//aside[@class='visible-md visible-lg col-md-4 clearfix ng-scope']//button[@class='btn btn-success btn-block continueButton']"))).Click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352