Using Selenium Java, how to create our own locating mechanisms by extending the "By" class

50 views
Skip to first unread message

Sundaram Iyer

unread,
Sep 7, 2021, 12:36:42 AM9/7/21
to Selenium Users
Can someone share  an example code in Selenium with Java where we can create our own locating mechanism?

as per the documentation, it says:              

"By" is an abstract class for locating elements. So to create own locating mechanisms, it is possible to subclass this class and override the protected methods as required.

Inside the "By" class I see only two protected methods. But I am not sure how to override them in order to create my own locating mechanisms. Please help if someone has used this before.

 
These are the two protected methods inside the "By" class

Thanks

Serguei Kouzmine

unread,
Sep 25, 2021, 1:16:59 AM9/25/21
to Selenium Users
See how set of  custom By is implemented in https://github.com/sergueik/jProtractor
feel free to ask  further questions

Serguei Kouzmine
Reply all
Reply to author
Forward
0 new messages