0

I try to scrape this site with Python-selenium, my problem is when i launch my script in local it works and i scrape all the articles, but when i launch my script in server, i should run my code Headlessly with Xvfb

display = Display(visible=0, size=(1024, 768))
display.start()

and in this case, the NEXT PAGE button disappear and my script can't click in next page button.

i try to click

xpath_path = 'a.jsNxtPage.pgNext'
      try:
          element = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.CSS_SELECTOR, xpath_path)))
      finally:
          driver.execute_script("arguments[0].click()", element)

it works in local but not when i use Headless Testing in server

i tried also with chrome and firefox.

parik
  • 2,313
  • 12
  • 39
  • 67
  • Why is not working in Headless Testing in server?? is there any exception or something else?? – Saurabh Gaur Sep 29 '16 at 11:51
  • @SaurabhGaur because the NEXT PAGE button disappears " i took a screen shot", but when i use normal webdriver in local i see the process i see the next page and everything works. – parik Sep 29 '16 at 12:08
  • instead of `presence_of_element_located` try using `element_to_be_clickable` as `element = WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.CSS_SELECTOR, xpath_path))) element.click()` and let me know – Saurabh Gaur Sep 29 '16 at 12:13
  • @SaurabhGaur did you recieve my answer? your answer is deleted – parik Sep 29 '16 at 13:30

0 Answers0