Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97813

click() not working on difficult to navigate website

$
0
0

I'm fairly new to Python and very new to Selenium. I want to click on a button on a website that has no class or id attributes.

I've tried using XPath with find_element_by_xpath() and click() but either doesn't seem to do anything or just generates an error.

from selenium import webdriver
from config import my_user, my_password


browser = webdriver.Safari()
browser.set_window_size(1600, 1200)
browser.set_window_position(0, 0)
browser.get('http://thefutoncritic.com/myfuton/listings/')

email_box = browser.find_element_by_name('email')
email_box.send_keys(my_user)
password_box = browser.find_element_by_name('password')
password_box.send_keys(my_password)
password_box.submit()

listings_button = browser.find_element_by_xpath(
    '//html/body/div/table/tbody/tr[1]/td[1]/table[4]/tbody/tr/td[6]/div/a')
listings_button.click()

Excerpt from website:

<tbody><tr height="37">
...
<td width="150">
<div style="width:150; height=37; background-image:url('/images/my-listings.jpg'); background-position:0 -37px;">
<a href="/myfuton/listings/"><img src="/images/spacer.gif" width="150" height="37" border="0">
</a>
</div>
</td>
</tr>   
</tbody>
Traceback (most recent call last):
  File "/Users/tspgallagher/Projects/Python/Sandbox/temp2.py", line 17, in <module>
    listings_button.click()
  File "/Users/tspgallagher/Library/Python/3.7/lib/python/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "/Users/tspgallagher/Library/Python/3.7/lib/python/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "/Users/tspgallagher/Library/Python/3.7/lib/python/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/Users/tspgallagher/Library/Python/3.7/lib/python/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: 

Viewing all articles
Browse latest Browse all 97813

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>