0

Im trying to scrape a javascript page using selenium and having some problems clicking through. The click does not go to another page but uses javascript to bring up the next ten reviews, which I want to scrape.

The first click seems to work but the second click never works, always saying there is no element exists.

the code im using is

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.by import By

browser = webdriver.Firefox()
browser.get("http://www.agoda.com/the-coast-resort-koh-phangan/hotel/koh-phangan-th.html")
delay = 3 # seconds
xpath = "//a[@id='next-page']"
try:
    WebDriverWait(browser, delay).until(expected_conditions.element_to_be_clickable((By.XPATH, xpath)))
    print "Page is ready!"
except TimeoutException:
print "Loading took too much time!"

browser.find_element_by_xpath("//a[@id='next-page']").click()

try:
    WebDriverWait(browser, delay).until(expected_conditions.element_to_be_clickable((By.XPATH, xpath)))
    print "Page is ready!"
except TimeoutException:
    print "Loading took too much time!"

browser.find_element_by_xpath("//a[@id='next-page']").click()

try:
    WebDriverWait(browser, delay).until(expected_conditions.element_to_be_clickable((By.XPATH, xpath)))
    print "Page is ready!"
except TimeoutException:
    print "Loading took too much time!"

which gives

Page is ready!
Page is ready!
WebDriverException: Message: Element is not clickable at point

Any ideas why this is not working, I have checked that the element to click is there.

What I dont understand is that it says the page is ready, therefore it has found the element I am trying to click but then when I go and click on this element it then says the element is not clickable?

Runner Bean
  • 4,895
  • 12
  • 40
  • 60
  • Selenium tries to click in the middle of the element, and for some reason it appears like your element is not clickable in the middle for some reason. It can be found, and is clickable, just not at the point it is trying to click. element_to_be_clickable checks if the element is visible and enabled, but does not actually check if the middle of the element is clickable itself. perhaps try to scroll down the page a bit so the arrow element is completely in view? – Mobrockers May 30 '16 at 17:03
  • See [this](https://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error) stackoverflow post about this issue. – Mobrockers May 30 '16 at 17:24

1 Answers1

-1

Here I Will Put Code Which Navigate Page in that I have used Chrome Driver: You can download from here:Chrome Driver

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.by import By
import time

browser = webdriver.Chrome("./chromedriver.exe")
browser.get("http://www.agoda.com/the-coast-resort-koh-phangan/hotel/koh-phangan-th.html")
delay = 3 # seconds
xpath = "//a[@id='next-page']"

try:
    for i in range(0,5):
        browser.find_element_by_id("next-page").click()
        time.sleep(5)
        print i
except Exception as e:
    print e

time.sleep(5)
browser.quit() 
Piyush
  • 511
  • 4
  • 13