user-defined methods in Selenium

20 views
Skip to first unread message

Tony Chamberlain

unread,
Jun 20, 2018, 8:43:18 AM6/20/18
to Selenium Users
Is there any way to make user-defined Selenium methods?  For instance, in the version of Selenium we use there is no ends-with().  So I have to do something like
//input[substring(@id, string-length(@id) - string-length('_PHONE$1') +1) = '_PHONE$1'] instead of //input[ends-with('_PHONE$1')].

So if I could do something like (and this is just an example):

define my-ends-with(String endsWith) {
     substring(@id, string-length(@id) - string-length(endsWith) +1) = endsWith
}
I am using Java and Eclipse and Chrome and Selenium.  The selenium version is the one with Chrome that does not have an ends-with().
Chrome == 67.0.3396.87
Java 1.8
Reply all
Reply to author
Forward
0 new messages