TD / TR Input - Selenium

1

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

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

But it returns me:

  

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

But validating in Chrome Xpath, is correct.

Note: I tried to use FindElements , there it finds, but I can not get the SendKeys command is not part of it.

BelowisalsotheformHTMLthatI'maccessing.

<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>

    
asked by anonymous 21.11.2018 / 13:44

1 answer

0

Try using By.Name ("user") as a search parameter, otherwise you will have to do some testing, and you can try to define it by JavaScript. You can do something like:

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