0
我想在CircleCI的測試階段運行一些python硒測試。在CircleCI上運行python硒測試
我circle.yml看起來是這樣的:
machine:
python:
version: 2.7.9
node:
version: 0.10.34
java:
version: oraclejdk8
dependencies:
post:
- pip install selenium
- wget http://selenium-release.storage.googleapis.com/2.44/selenium-server-standalone-2.44.0.jar
- java -jar selenium-server-standalone-2.44.0.jar:
background: true
test:
post:
- python /home/ubuntu/app/tests/tests.py
...
和tests.py看起來是這樣的:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://127.0.0.1')
print driver.find_element_by_class_name('a-class').text
我有兩個問題:
首先,如何I輸出數據從test.py返回到CircleCI的界面(打印語句顯然不起作用)
其次,在撥打電話driver.get()
時使用的正確地址是什麼,因爲我收到http://127.0.0.1/ is not available
錯誤?
以下是完整回溯:
http://127.0.0.1/ is not available
Traceback (most recent call last):
File "/home/ubuntu/app/tests/tests.py", line 11, in <module>
print driver.find_element_by_class_name('yes-cta').text
File "/home/ubuntu/virtualenvs/venv-2.7.9/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 378, in find_element_by_class_name
return self.find_element(by=By.CLASS_NAME, value=name)
File "/home/ubuntu/virtualenvs/venv-2.7.9/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 712, in find_element
{'using': by, 'value': value})['value']
File "/home/ubuntu/virtualenvs/venv-2.7.9/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "/home/ubuntu/virtualenvs/venv-2.7.9/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element
(Session info: chrome=43.0.2357.130)
(Driver info: chromedriver=2.16.333243 (0bfa1d3575fc1044244f21ddb82bf870944ef961),platform=Linux 3.13.0-76-generic x86_64) python /home/ubuntu/app/tests/tests.py returned exit code 1
假設您在執行查找之前並未等待頁面加載,但請提供一個跟蹤,以便我們可以確定實際的錯誤。 –
用追溯編輯。我不確定在'driver.get'調用中使用什麼。 – Andrew
這是您要測試的網址。我懷疑你的網絡服務器是否在127.0.0.1端口80上運行... –