-3

maybe a dumb question. I'm not getting in the dropdown menu find_element_by_xpath. Only getting find_element and find_elements.

rukon
  • 1
  • Please provide enough code so others can better understand or reproduce the problem. – thedemons Oct 20 '22 at 00:14
  • Sorry first time userfrom selenium import webdriver from selenium.webdriver.common.keys import Keys import time driver = webdriver.Edge('C:\msedgedriver.exe') driver.get('https://www.google.ca/') driver.maximize_window() box = driver.find – rukon Oct 20 '22 at 02:44
  • always put code, data and full error message as text (not screenshot, not link) in question (not in comment). It will be more readable and easier to use in answer (simpler to select and copy), and more people will see it - so more people can help you. – furas Oct 23 '22 at 11:42

1 Answers1

0

Your code snippet isn't enough in any way.

With that in mind:

Please be aware that the Xpath locator is very finnicky.

It depends on the HTML you see and selenium loads a slightly different version of the HTML breaking the xpath.

 /html//div/div/div/div[1]/div/a/img

Is unlikely to ever work, prone to breaking the second the tiniest change is done to an HTML and you are probably going to waste hours figuring out what each of the absolute xpaths is accesing when the website is updated.

You should use advanced xpath features to make relative xpaths that are more robust when the website changes.

https://www.lambdatest.com/blog/complete-guide-for-using-xpath-in-selenium-with-examples/ has some basic pointers on where to get started with good xpath locators.

dot
  • 64
  • 7