Home > other >  locate html element that change position with selenium Python
locate html element that change position with selenium Python

Time:04-29

List:

List

So i have this list and need a way to find any of the users, the problem is that the position of users changes and with xpath is imposible because the div position takes the users thats in that div, not the user that a want to find

//*[@id="main-el"]/div[3]/div/div[2] #the last div number is the location of user

and on top of that the users element doesnt have any unique identification other than the xpath or css colector

so, any help?

im putting here the hmtl element too if someone needs it, is there other way to find the element?

Html Code of element:

CodePudding user response:

Never mind i got it

i just had to find an unique property of the div, in my case was

"data-rbd-draggable-id" of the user div, so i put this Xpath

//div[@data-rbd-draggable-id="US_true_af26b3c3-4216-43e0-ba73-9ad890058060"]

and it worked, it detects the user prueba1 element even if it changes position

CodePudding user response:

from selenium.webdriver import ActionChains

actions = ActionChains(self.driver)
el = self.driver.find_element_by_xpath("locator")
actions.move_to_element(el).perform()
  • Related