Search code examples
pythonseleniumscreen-scraping

How to find the path of a button in a web page


I'm scraping this page:

http://www.bbb.org/atlanta/business-reviews/heating-and-air-conditioning/cool-flame-heating-and-air-in-powder-springs-ga-1009/customer-reviews?cacheit=y

and need to press the button to see the reviews.

with chrome I get this path

//*[@id="myspanpos"]

But when I try the scrip:

NEXT_BUTTON_XPATH = '//*[@id="myspanpos"]'
button = browser.find_element_by_xpath(NEXT_BUTTON_XPATH)
button.click()

got:

 Unable to locate element: {"method":"xpath","selector":"//button[text()=\"myspanpos\"]"}

Solution

  • To open "Reviews" drop-down window you need to click on anchor tag element (<a>), not on <span>. So use

    browser.find_element_by_id('close_open').click()