I am trying to get the Xpath of a label text in a web page that I am trying to automate. The application is angular based, so there are a lot of angular related stuff on the page.
However, I am trying to automate this using Selenium and Python. The element in question is the error message highlighted in the image -
The html pertaining to the error message is highlighted in the section below. What would be suitable locator for this element?
I have tried a lot of combinations- using Xpaths and CSS, but I am coming up empty handed. The absolute xpath - which is
html/body/app-root/ng-component/div/div/div[2]/form/div[2]/div/label
is the only one that works for this case, but I don't want to use it.
Some of the combinations that I have tried - using Xpath's
//form[@class='ng-untouched']/div[2]/div/label
//div[@class='login-inner']/div/label
both of these don't work and Selenium throws a NoSuchElement
exception.
Using CSS Selector, I used this -
element.find_element_by_css_selector(".login-inner.ui-g-12 div label")
Any kind of help would be appreciated.