java - How to find element of textfield with selenium WebDriver? -
I have an example with Google Please explain to me, what does that mean? .findElement (by.name ( "Q"));
How WD understands this is a text field?
WebDriver driver = new HtmlUnitDriver (); // and now use it to see Google driver. ("Http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement (by.name ("q"));
Selecting this one element with q
Its name
attribute does not know that the element is a input
, it is simply specifying it on WebElement
.
If you want to determine that this is a input
you can call and type through
example
WebDriver driver = new FirefoxDriver (); // and now use it to see Google driver. ("Http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement (by.name ("q")); If (element.getTagName (.) Equally ignored cass ("input") and amp; amp; amp; amp; amp; element element.getAttribute ("type"). Equal ignoreCase ("text" }) {System.out.println ("Its a text box"); }
Comments
Post a Comment