Skip to content
Advertisement

Python selenium google map elements unable to locate

the code I’m trying to find elements are

driver.implicitly_wait(5)
print(driver.find_element_by_xpath('/html/body/div[6]/div/div[8]/div[2]/div/div[2]/async-local-kp/div/div/div[1]/div/div/div/div[1]/div/div[1]/div/div[4]/c-wiz/div').text)

rating = driver.find_element_by_xpath('/html/body/div[6]/div/div[8]/div[2]/div/div[2]/async-local-kp/div/div/div[1]/div/div/div/div[1]/div/div[1]/div/div[1]/div/div[2]/div[1]/div/div').text
print(rating)
address = driver.find_element_by_xpath('/html/body/div[6]/div/div[8]/div[2]/div/div[2]/async-local-kp/div/div/div[1]/div/div/div/div[1]/div/div[1]/div/div[5]/div/div[2]/div/div').text
print(address)

here is the element I’m trying to access please check the image google page image

the url of the google page is google page link

but it says elements unable to find I’m using full xpath

Advertisement

Answer

just right click on what you need and press inspect tried it on the review and it worked for me

SELECTOR:

#akp_tsuid37 > div > div:nth-child(1) > div > div > div > div.kp-blk.knowledge-panel.Wnoohf.OJXvsb > div > div.ifM9O > div > div.kp-header > div > div:nth-child(2) > div:nth-child(1) > div > div > span.Aq14fc
Advertisement