Action: Retrieving the value from a text box using the GetText() method with Selenium webdriver.
HTML code:
<input class="form-control ng-pristine ng-valid dirty ng-touched" type="text" placeholder="Search Query" my-enter="SaveBind('Search');" ng-model="Query.SearchTerm" name="headerSearch">
The above code represents an input type with text control, thus requiring the extraction of the value from the text box.
My Xpath:
@FindBy(how = How.XPATH, using = "//input[@ng-model='Query.SearchTerm']")
public WebElement searchQuery;
When utilizing the getText method, an empty value is retrieved.
String query = searchQuery.getText();
However, sending the value through sendKeys works correctly as the entered value is pasted into the control.
searchQuery.sendKeys("Welcome");
My inquiry: If the entered values are not displayed in the HTML tag, how can the value be extracted from the text box? Is it possible to automate Angular Js?
Attached screenshot: https://i.sstatic.net/bJLZo.png