I need to copy a value that is in "value". I am using Eclipse Java Selenium Library

Asked

Viewed 370 times

0

This is the html:

input name="nr_proposta" type="text" value="52367" data-mask="9?99999999" data-mask-placeholder=" " class="form-control apagar" id="nr_proposta"

In java I’m doing so:

WebElement nrProposta = driver.findElement(By.cssSelector("div:nth-child(5) > div:nth-child(1)"));
WebElement nrProposta2 = driver.findElement(By.name("nr_proposta"));

System.out.println("N Proposta:       " + nrProposta.getText());         
System.out.println("N Proposta:2      " + nrProposta2.getText());

This way returns to me null or blank...

When I use nrProposta.getAttribute("value"); he returns me null.

  • when you give nrProposta.toString() it returns the whole tag?

1 answer

0

You have 2 ways, can try to catch what is visible in the element with the

nrProposta.getText()

which I believe in your case will suffice.

or take an element attribute with the `

nrProposta.getattribute("taxonName")

`

Browser other questions tagged

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