2017-06-29 126 views
0

尝试使用python脚本时自动执行问题。我可以通过GIT访问存储库,其中python文件夹全部使用Python 2.7语法。我也有chrome驱动程序(使用ubuntu)。当我尝试自动化时,我只是得到错误,关于Python 2.7。不确定这是否是问题。尝试执行python脚本时使用chrome驱动程序时出错

我被给了一个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 

因此不确定如何解决它。试图帮助我的朋友也很难过。我使用pip安装硒& pip安装鼻子。不确定是否需要安装其他任何东西。所以任何指导/帮助将不胜感激。任何含糊的东西,我都会尽力提供更好的细节。希望这个问题与本节的计算器相关。感谢您的阅读

+1

确保您的镀铬驱动程序二进制文件属于同一用户组在运行了程序与 – Arount

+0

这是用户读写和执行它 – BoboDarph

+0

我从你在Linux上的文件路径假设权限。不幸的是,学习文件权限是非常必要的。所以你在阅读之前已经有了一些阅读,但是把所有这些都压缩成一个SO的答案是很难的。 –

回答

0

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

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

到:

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

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

export SELENIUM_CHROME_DRIVER=/home/myname/ChromeDriver/chromedriver.exe 

所以无论是我必须解决这个问题,或者它的其他路径/目录或R/W的问题。感谢您的评论。一旦我能得到这个修复程序,我会在几个小时内解决!

----------- ----------- UPDATE

如果能够解决自动化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 
+0

能够正确自动化。虽然很多工作 – kay19

0

Ubuntu的, 右击chromedriver文件,单击属性,单击权限,勾选“允许执行文件作为程序“。

相关问题