Quality Testing

Quality is delighting customers

I need some help with finding the elements using webdriver. How do I find them???

  1. On the webpage this is the label 'Password'

< div _ngcontent-c1="" class="form-group text-left">

< label _ngcontent-c1="">Password

2.On the webpage this is the textbox for 'Password'

< input _ngcontent-c1="" class="form-control ng-untouched ng-pristine ng-invalid" formcontrolname="Password" placeholder="" type="password" autocomplete="off" style="background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAAAXNSR0IArs4c6QAAAXFJREFUOBGVVDGKwkAUfZHFaBBS2riQSrC18QJpAvbeYAVbD6DxFm4TELyA1R7BKmUgjRa7pAwELKKF2XljEuMSN/HDZOb//96b+X+GKLZtW0mSrMV4Rw1TFOVbwD6Wy+UX4Y1XyCSkG31yTaNArZ1v8Nu3yGkUE1VrTdPQ7/cfYC8JGIYB0zTLBVqtVp5QVRWiWblfzOXBdPHGeTweYzgcYrvdIgxDzGYzBEEAx3Eecn/J9F8qoUxAWSwWCRM8ZhzHEsMSzudzGT6PiRJ/hDPNT5CRiagiEyOusiemtewBA//ZZDLBYDDIIavVCtfrVYrUEmi324iiCPv9XoqQnFkjfduZXzpToNlsykdUJBNMgWmViO/78DwPuq7DsizwQWV2fy1ZJJ2z26Hb6XRwOp0wGo2kwG63g+u6ElmrB/P5XApQ6HK54HA4pNsATwV4z+lVYbPZoNvtys6zHDaURsxTAZFnb/ij6R2PR3AUjWRifgHmko6KAvVfRAAAAABJRU5ErkJggg=="); background-repeat: no-repeat; background-attachment: scroll; background-size: 16px 18px; background-position: 98% 50%;"/>

  1. On the webpage this is the button 'Login'

< div _ngcontent-c1="" class="text-right col-xs-4 col-sm-4 col-md-4 login-submit no-side-padding"> Login< /button >

Views: 93

Reply to This

Replies to This Discussion

There are multiple ways of locating elements at the page, since we cannot see the code the answers will assume XPath locators as it's the most powerful (on the other hand it might be the slowest one)

  1. //label[text()='Password']
  2. //input[@type='password']
  3. //button[text()='Login']





There are numerous ways an automation engineer working on test automation services with which he can find the web elements on a web page.

Using xpath:

1. //label[text()='Password']]
2. //input[@class='form-control ng-untouched ng-pristine ng-invalid'] or //input[@type='password']
3. //button[text()='button'] or //button[@class='text-right col-xs-4 col-sm-4 col-md-4 login-submit no-side-padding']

Using Css(you can directly use 'attribute.className'):

1. div.form-group.text-left or label[text='Password']]
2. input.form-control.ng-untouched.ng-pristine.ng-invalid or input[type='password']
3. button.text-right.col-xs-4.col-sm-4.col-md-4.login-submit.no-side-padding or button[text='button']

Make sure there are no spaces in class name and replace the spaces with dot(.) in class name when you use Css.

To locate the web elements you can either use the 'Chropath' adddon(available in both latest versions of Chrome and Firefox) or Inspect the element -> Right click on the highlighted HTML code -> Copy -> Copy Xpath or Copy Css Selector.



TTWT Magazine





© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service