1

I am using python with selenium for automation on windows.

I used inspect element to find a element and do some operation on it. It worked perfectly fine for me.

a= self.driver.find_element_by_xpath('//*[@id="dia2"]/p')

My colleagues followed the same method, but got a different xpath.

a= self.driver.find_element_by_xpath('//*[@id="dia4"]/p')

and his code didnt worked on his machine. When he repleaced dia4 with dia2- his code worked. Any idea, why we are getting different xpath from 2 different machines. We both used windows, same website, same element. What other factors determine xpath. I will check them on both machines.

Saurabh Shrivastava
  • 1,394
  • 4
  • 21
  • 50

1 Answers1

0

It is hard to describe without knowing the type of Exception that was thrown.

I had similar experience when I was running my test on mobile machines. The application code worked in a way it hid some DOM objects when resolution was different and shown those which were hidden. (DOM objects were visible to webDriver but were not displayed) I handled it by getting the list of elements that were matching my criteria and loop through them to find out which of them was visible.

Piotroslav
  • 252
  • 1
  • 4
  • 14