How to click these elements using Python and Selenium?

Hello,

I am trying to click on the following elements on bing chat website using Python and Selenium.

  • //*[@id=“tone-options”]/li[3]/button
  • //*[@id=“camera-container”]/button
  • //*[@id=“camera-container”]/cib-flyout/cib-visual-search//div[3]/button[1]

I have tried using CSS, XPath, and name selectors, but none of them seem to work. Could somebody please help me with this?

Thank you.

I usually take the approach of selecting the element with right click and inspect, then on the inspect console I copy the JS path, document.querySelector("#post_1 > div > div.topic-avatar > div > a > img") for your avatar for example.

Then try it on the console with document.querySelector and document.querySelectorAll to check if i got the right thing.

image

Also it might be that you are trying to get the elements without them properly loading to the DOM so you might want to implement some implicit or explicit waiting strategies.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.