Home > Software design >  I can not find the element (input tag) on the page
I can not find the element (input tag) on the page

Time:10-04

I'm trying to enter username and password to login to my bank account by VBA. I can find the password Input Tag to enter the password, but cannot find the userform Input Tag at all. I tried the following methods one by one, but none of the Find methods worked and there is no other attributes for this tag which I can look for.

Dim Mybrowser As New WebDriver
Set Mybrowser = New WebDriver
Mybrowser.Start "chrome"
Mybrowser.Get "https://tbconline.ge/tbcrd/login?t=false"

Mybrowser.FindElementByName("loginUsername1633281403139").SendKeys ("test")
'or
'Mybrowser.FindElementByClass("fblock100 > .ng-valid").SendKeys ("test")
'or
'Mybrowser.FindElementByCss("css=.fblock100 > .ng-valid").SendKeys ("test")
'or
'Mybrowser.FindElementByXpath("//input[@name='loginUsername1633281403139']").SendKeys ("test")
'or
'Mybrowser.FindElementByName("loginPassword1633282058600")

Am I making a mistake in the code ? or is it true that sometimes we cannot find some elements by find method on a page, although they exist there ? Thanks for your advice.

CodePudding user response:

The Name or CSS that you've used, looks brittle in nature, Probably generated by backend framework, so on every run they will change, Please use customize and optimize CSS or Xpath from below.

Note that CSS has more preference than XPATH

Please use this css for username

input[formcontrolname='username']

xpath

//input[@formcontrolname='username']

for password field :

css

input[formcontrolname='password']

xpath

//input[@formcontrolname='password']

You can learn CSS from here.

  • Related