Reputation: 65
I'm trying to get the xpath of the element on the page, and I can't find it in the html code of the page (the Inspect button is not avaliable, too). I was wondering if there is any function to get the xpath of the button that I press in Selenium WebBrowser. For example, if I press the "python" button, I want Selenium to write to console something like: "Button pressed! The xpath: ..."
Is there any possibility to do that?
Upvotes: 3
Views: 130
Reputation: 2183
There are lot of posiibilities.
You can implement your POM with the loging files, that is on of the way how you can be aware that you click at some button and have the xpath of your button.(Note: That method from POM will be called only for clicking, just to make sure that follow your question)
In that case for button locator you will also need to use xpath, and when you are trying to get your Pom and click on it (specific Web eleemnt ) you will log the message which you want.
For loging in Java you can use log4j library, and for Pyton you can use autopylogger library.
Upvotes: 2