Thursday, April 3, 2025

selenium webdriver – Xpath to an anchor returning error: unable to find component


I’m new to automated testing. I’m utilizing C#, Selenium and Chrome 99 with the right driver. I’m making an attempt to get to an anchor tag on the web page.

Right here is my code that’s not working,

driver.Url = "abc.com"; //cant show the actual one
driver.FindElement(By.XPath("//a[@href="https://sqa.stackexchange.com/questions/49922/ubEntryQueue.aspx"]")).Click on();

The error I get:

OpenQA.Selenium.NoSuchElementException
  HResult=0x80131500
  Message=no such component: Unable to find component: {"methodology":"xpath","selector":"/a[@href="https://sqa.stackexchange.com/questions/49922/ubEntryQueue.aspx"]"}
  (Session information: chrome=99.0.4844.74)
  Supply=WebDriver
  StackTrace:
   at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.WebDriver.FindElement(String mechanism, String worth)
   at OpenQA.Selenium.By.<.ctor>b__11_0(ISearchContext context)
   at OpenQA.Selenium.By.FindElement(ISearchContext context)
   at OpenQA.Selenium.WebDriver.FindElement(By by)
   at CLQTesting.WQ.ValidateWQDisplays() in C:QACLQTestingWQ.cs:line 30

This was my final try

Here’s what I’m making an attempt to get to

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles