Input on TD/TR - Selenium

Asked

Viewed 262 times

1

I’m setting up a system to automate a routine here in the company, but has a specific site that uses the field form inside TD's/TR's, so I was using:

driver.FindElement(By.XPath("//input[@name='user']")).SendKeys("Teste");

But he returns to me:

Openqa.Selenium.Nosuchelementexception: 'Unable to find element with xpath == //input[@name='user']'

But validating Xpath in Chrome is correct.

Note: I tried using the FindElements, there he finds, but I can’t get the command SendKeys is not part of this.

inserir a descrição da imagem aqui

Below also has the form HTML that I am accessing.

<tbody><tr><td colspan="2" bgcolor="#ffffff" align="center"><font size="3" face="Verdana"><b>Identificação do Usuário</b></font></td></tr>
<tr><td>&nbsp;</td></tr>
<tr>
    <td><font size="2" face="Verdana"><b>Usuário</b></font></td>
    <td align="right"><input name="user"></td>
</tr>
<tr>
    <td><font size="2" face="Verdana"><b>Senha</b></font></td>
    <td align="right"><input type="password" name="passwd"></td>
</tr>
<tr>
    <td><font size="2" face="Verdana"><b>Ramal</b></font></td>
    <td align="right"><input name="ramal" maxlength="10"></td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr><td colspan="2" align="center">
    <input type="submit" name="entrar" value="Acessar" style="width:100px" language="javascript" onclick="return entrar_onclick()"> 
    <input type="submit" name="senha" value="Alterar Senha" style="width:100px" language="javascript" onclick="return senha_onclick()">
</td></tr>

  • You have not reported what language you are using, but try to change xpath for css selector and use input[name=user] as parameter to see if you have the desired result

  • Sorry, I’m using C#

  • I had tested, but presents another error stating that did not identify. Openqa.Selenium.Nosuchelementexception: 'Unable to find element with css selector == input[name=user]'

  • you may have to put requests before and after the word user

  • Same situation Openqa.Selenium.Nosuchelementexception: 'Unable to find element with css selector == input[name='user']'

  • You are waiting for the screen to load before trying to access the element?

  • So I don’t use Thread to wait, because I use it on several other sites and I don’t have a problem, it’s just a Checklist system, the only site that’s giving me a headache is this. A Situation is simple, then "print" the screen and saved.

  • You saw that tag input is not being closed? It may have something to do with your problem

  • you say in HTML? is third party application.

  • Closed, I selected the Iframe that was the TD/TR and managed to map through Xpath. Thank you.

Show 5 more comments

1 answer

0

Try using By.Name("user") as a search parameter, in case you don’t have to do some tests, and you can try setting by Javascript. You can do something like:

var element = driver.FindElement(By.Name("user"));
if(element != null)
    driver.ExecuteJavaScript("arguments[0].value = 'Teste'", element);

Browser other questions tagged

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