Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试执行python脚本时使用chrome驱动程序时出错_Python_Git_Python 2.7_Google Chrome_Selenium - Fatal编程技术网

尝试执行python脚本时使用chrome驱动程序时出错

尝试执行python脚本时使用chrome驱动程序时出错,python,git,python-2.7,google-chrome,selenium,Python,Git,Python 2.7,Google Chrome,Selenium,在使用python脚本时,在尝试自动化时遇到问题。我可以通过GIT访问存储库,其中python文件夹都使用Python2.7语法。我也有chrome驱动程序(使用ubuntu)。当我尝试自动化时,我只得到了一个关于Python2.7的错误。不确定这是否是问题所在 我得到了一个python代码,该代码将使用chrome驱动程序来测试我是否可以自动使用python代码,该代码是为执行后使用而编写的。使用命令终端,我得到以下错误: traceback (most recent call last):

在使用python脚本时,在尝试自动化时遇到问题。我可以通过GIT访问存储库,其中python文件夹都使用Python2.7语法。我也有chrome驱动程序(使用ubuntu)。当我尝试自动化时,我只得到了一个关于Python2.7的错误。不确定这是否是问题所在

我得到了一个python代码,该代码将使用chrome驱动程序来测试我是否可以自动使用python代码,该代码是为执行后使用而编写的。使用命令终端,我得到以下错误:

traceback (most recent call last):
File "autotimesheet.py", line 254, in <module>
    processPDCI(res)
File "autotimesheet.py", line 85, in processPDCI
    driver = webdriver.Chrome('/home/myname/ChromeDriver')
File "/home/myname/.local/lib/python2.7/site-
       packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
self.service.start()
File "/home/myName/.local/lib/python2.7/site-
       packages/selenium/webdriver/common/service.py", line 86, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver' 
executable may have wrong permissions. Please see 
https://sites.google.com/a/chromium.org/chromedriver/home
回溯(最近一次呼叫最后一次):
文件“autotimesheet.py”,第254行,在
过程PDCI(res)
processPDCI中第85行的文件“autotimesheet.py”
driver=webdriver.Chrome(“/home/myname/ChromeDriver”)
文件“/home/myname/.local/lib/python2.7/site-
packages/selenium/webdriver/chrome/webdriver.py”,第62行,在__
self.service.start()
文件“/home/myName/.local/lib/python2.7/site-
packages/selenium/webdriver/common/service.py”,第86行,开头
os.path.basename(self.path)、self.start\u错误消息)
selenium.common.exceptions.WebDriverException:消息:“ChromeDriver”
可执行文件可能有错误的权限。请看
https://sites.google.com/a/chromium.org/chromedriver/home

所以不确定如何解决它。那个试图帮助我的朋友也被难住了。我已经使用pip安装selenium和pip安装nose进行设置。不确定我是否需要安装其他东西。因此,任何指导/帮助都将不胜感激。任何含糊不清的地方,我都会尽量提供更好的细节。希望这个问题与stackoverflow的这一部分相关。感谢您阅读

只是一个更新。我能够使脚本自动化。这是我做的唯一一步:在autotimesheet.py中,我更改了以下代码行:

driver = webdriver.Chrome('/home/myname/ChromeDriver/)
致:

其中最后一部分是可执行文件。所以它打开了chrome并开始自动化。既然我知道这可以自动化,就必须解决存储库部分的问题。在我的.profile中,我有以下内容:

export SELENIUM_CHROME_DRIVER=/home/myname/ChromeDriver/chromedriver.exe
所以要么我必须解决这个问题,要么它是另一个路径/目录或r/w问题。谢谢你的评论。我将解决在几个小时后,一旦我可以得到这个修复

-----------更新-----------

为了解决自动化python脚本问题,我必须解决最后一个问题。我仍将遵循这些评论,并进行故障排除。如果任何人有类似问题,我的错误供将来参考:

错误:tests.test_to_run.TestsToRun.test_run_this_test

Traceback (most recent call last):
File "/home/myName/.local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File 
"/home/myname/Automation/pdci_keyword/python/tests/test_to_run.py", 
line 25, in test_run_this_test
self.test_controller.insert_steps_from_script_into_list_array()
 File 
 "/home/myName/Automation/pdci_keyword/python/lib/
web_interface/test_controller.py", line 337, in 
insert_steps_from_script_into_list_array
self.process_msg_insert(data)
 File 
"/home/myName/Automation/pdci_keyword/python/lib/web_interface/
test_controller.py", line 200, in process_msg_insert
ubuntu,
右键单击chromedriver文件,单击属性,单击权限,勾选“允许将文件作为程序执行”。

确保您的chrome驱动程序二进制文件属于运行程序的同一用户和组,并且该用户具有itI的读写和执行权限,我假设您在linux上。不幸的是,了解文件权限几乎是强制性的。所以你前面有一些阅读材料,但是很难把所有这些都压缩成一个简单的答案。好的,谢谢你的评论!我将检查设置/路径/R&W权限以及故障排除,稍后将更新此主题。能够正确自动执行。不过还有很多工作要做
Traceback (most recent call last):
File "/home/myName/.local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File 
"/home/myname/Automation/pdci_keyword/python/tests/test_to_run.py", 
line 25, in test_run_this_test
self.test_controller.insert_steps_from_script_into_list_array()
 File 
 "/home/myName/Automation/pdci_keyword/python/lib/
web_interface/test_controller.py", line 337, in 
insert_steps_from_script_into_list_array
self.process_msg_insert(data)
 File 
"/home/myName/Automation/pdci_keyword/python/lib/web_interface/
test_controller.py", line 200, in process_msg_insert