Cannot run python Selenium script under localhost

☆樱花仙子☆ 提交于 2019-12-08 06:45:21

问题


I´m newbie to python and selenium. I´m creating app with GUI in web browser and the logic is executed in python under Apache. I have written some selenium scripts that work perfect when testing seperately outside Apache. But when I try to execute Selenium script under Apache on localhost, new Chrome or Firefox window won´t open. Apache with Python is confugured correctly --> able to run other python scripts. So here is my code:

PYTHON

!#path to python
from selenium import webdriver
import selenium.webdriver.chrome.service as service

service = service.Service('C:\\wamp64\\www\\chromedriver.exe')
service.start()
capabilities = {'chrome.binary': 'c:/Program Files (x86)/Google/Chrome/Application/chrome.exe'}
driver = webdriver.Remote(service.service_url, capabilities)
driver.get('https://www.google.com/')

#Here is code to get var div_text

print("Content-type: text/html\n\n")
print(div_text)

I am quite lost here, because new Chrome window won't open a Apache error log is empty. What am I missing here? Tested on python 3.4.0 and 3.6.3 with same results --> works fine from prompt (no Apache), doesn't work on localhost(Apache)

Only thing that came to my mind was that scripts on Apache server do not have the permission to execute WIN apps.

Thanks for your advice

来源:https://stackoverflow.com/questions/47756551/cannot-run-python-selenium-script-under-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!