1

Web driver couldn't find the x icon (Close) I used XPath and Full XPath to locate the x icon. Here's my code so far:

       webDriver.FindElement(By.XPath("*[@id='root']/div/div/div[1]/button")).Click();

I copied this *[@id='root']/div/div/div[1]/button by inspecting the element. The error displayed after running the automation testing is this:

Error screenshot

I also tried to use Katalon Studio to check if I could get the XPath, it did generate the XPath, but, once I pasted it, it's not working as well.

Cosmin
  • 2,354
  • 2
  • 22
  • 39
Bry
  • 25
  • 8
  • 1
    It's a bit hard for anyone to provide you with an answer when we don't have the site or HMTL snippet of the DOM. – Cosmin Jan 08 '21 at 09:17
  • Please improve your question, so that we can reproduce your issue. [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) Thanks – HedgeHog Jan 08 '21 at 09:24
  • Found the solution, since I'm trying to locate an element within an Iframe, I have to find the IFrame first, then switch to that Iframe before I could locate the element that I'm looking for and for this case, that element I was looking for was the button with x icon. – Bry Jan 13 '21 at 15:17

0 Answers0