Waruna Gunaratne Waruna Gunaratne - 7 months ago 25
AngularJS Question

Using selenium java need to retrieve data from angularjs

I need to retrieve data from the DB using angularjs to selenium java.

Below steps I tried but I couldn't retrieve data.

Use Selenium code---

HTML page source

`<div class="col-sm-6">
<input id="LastName" class="form-control ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required" type="text" required="" ng-model="UserProfiles.LastName" name="LastName" placeholder="Please Enter Last Name"/>

Selenium Java code

WebElement cityField = driver.findElement(By.cssSelector("input[ng-model='UserProfiles.FirstName']"));

System.out.println("Print- "+ cityField.getAttribute("input[ng-model='UserProfiles.FirstName"));

cityField = driver.findElement(By.cssSelector("input[ng-model='UserProfiles.LastName']"));
System.out.println("+++-- "+cityField.getText());`


Your code is attempting to get the text inside an "input" element, which will return nothing. Please try