1) You can use java script executor or change your xpath
2) Before writing an automated suite
-> You need to check which all browsers will script run on
-> Whether grid is needed
-> Whether parameterization is needed
-> Whether there is some component which gives difficulty in recognition