i wrote a python code using selenium to interact with a headless browser. Now I'm trying to transfer the program to my raspberry so I don't have to keep my Laptop online all the time. I altered the code a little for the use on the raspberry. The code for the PC works fine, but on the raspberry it stops to respond when trying to click on the button on the webpage. After a few minutes i get the following timeout error:
` File "AntenneReduced.py", line 52, in <module>
element1 = WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.ID, "gl-pl-pause")))
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
During handling of the above exception, another exception occurred:
`The code:
#!/usr/bin/env python
# coding: utf-8
# In[23]:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from pyvirtualdisplay import Display
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
#binary = FirefoxBinary('/home/pi/Dateien/usr/bin/firefox')
import time
STREAM='http://antennebayern.radio.de/'
print("vor display")
display = Display(visible=0, size=(800, 600))
display.start()
print("bis display")
opt=webdriver.FirefoxOptions()
opt.add_argument('headless')
driver = webdriver.Firefox(options=opt, executable_path='/usr/bin/geckodriver')
print("driver geladen")
# In[24]:
driver.get(STREAM)
print("Seite laden geht")
try:
element1 = WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.ID, "gl-pl-pause")))
print("Button ist schon geklickt")
except:
element = WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.ID, "gl-pl-play")))
element.click();
print("Button klicken geht")
# In[25]:
demo_div = driver.find_element_by_css_selector(".player__song > span:nth-child(2)")
driver.quit()
display.stop()
After the timeout it only has a slow response to commands until reboot.
I'm using a Raspberry3 B+ headless, python3 V3.5.3, Mozilla Firefox 52.9.0 and geckodriver V17