Exception in Selenium Webdriver c#

Asked

Viewed 29 times

-1

Hello, I’m having trouble at this point: Openqa.Selenium.Nosuchelementexception: 'no such element: Unable to locate element: {"method":"link text","selector":"Issue Payment Guide (DAS)"} (Session info: Chrome=91.0.4472.114)'

inserir a descrição da imagem aqui

1 answer

0

According to the message, it did not find a link with the text of the element. Try to find the element by another type of location, for example: CSS, ID, Name.

  1. Instead
driver.FindElement(By.LinkText("Emitir Guia de Pagamento (DAS)")).Click();

Try this:

driver.FindElement(By.Name("NameDoLinkDePagamento")).Click();

Or this:

driver.FindElement(By.ID("NameDoLinkDePagamento")).Click();

Or also a part of the text:

driver.FindElement(By.PartialLinkText("Emitir")).Click();
  1. In some cases, when the page has scroll, it is necessary to position the element at a height that facilitates the "visualization" of the element by chromeDriver. You can do this using Javascript, as below :
var alturaPagina = 600;
var _script = (IJavaScriptExecutor)_driver;
_script.ExecuteScript("window.scrollBy(0, alturaPagina)");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.