So I'm writing a Panel Object API for a website I'm testing with Selenium, and since this one is likely to be used by many people outside of my control in the future, I thought I may as well make it defensive (as seen in Effective Java). However, I've hit a wall when it comes to returning a clone of By.
I was expecting a method like arrayList has:
By newBy = new By(oldBy);
Doesn't exist as By is made statically. Further, I don't know of any way to get the information out of a By once the information is in there except for toString()
. So I can write a parser for By.toString()
, but that seems like a lot of effort for what the job is, and not very elegant to boot.
Can anyone suggest a less cumbersome way of cloning a By locator in selenium?