Home > Net >  Automatic click with Selenium, using By.XPATH
Automatic click with Selenium, using By.XPATH

Time:04-15

Do you see this little blue logo in the image below? Using WebDriverWait I would like to automatically click on this blue logo, in order to open the list of those who have left the likes.

enter image description here

I used By.XPATH., More precisely: //*[@id="jsc_c_z"]/span[1]/span/span/div , but it doesn't work. NOTA :I've noticed that the IDs and ranges on this page look suspiciously obfuscated and so maybe they won't necessarily be the same every time. So maybe I don't think id = "jsc_c_z" that will be reliable. You may need to resort to using aria-labeld of the attribute on the target element div.

My code is:

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="jsc_c_z"]/span[1]/span/span/div'))).click()

This instead is the link I would like to open enter image description here

PART 2 enter code here

I hope someone can help me. Thanks

CodePudding user response:

Can you try this?

//span[@data-hover='tooltip']/span

When I was checking this, I couldn't find the div tag you mentioned.

enter image description here

CodePudding user response:

Try this xpath:

(//*[@role='toolbar']//*[@role='button'])[1]
  • Related