Finding elements



  • I need some help with finding the elements using webdriver.

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

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

    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%;"/>
    </div >
    
    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">
         < button _ngcontent-c1="" class="btn btn-outline-primary btn-lg" 
           tabindex="4" type="submit" disabled="">Login< /button >
      </ div>
      



  • I would've used relative XPath. You can read about it here: https://www.guru99.com/xpath-selenium.html

    In your case it would be:

    1. //input[@class="form-control ng-untouched ng-pristine ng-invalid" ]
    2. //input[@formcontrolname = "Password" and type="password"] (or use only one property)
    3. //div[contains(text(), "Login")] OR //div[contains(@class, "login-submit")]


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2