0
我試着去運行一些測試,並正在到道路塊,硒不連接
這是腳本在那裏gettings抓的開始。
from selenium import selenium
import subprocess
import time
import sys
import socket
from os.path import dirname
import unittest
from pushdata import push
class selenium_tests(unittest.TestCase):
@classmethod
def setUpClass(self):
directory = dirname(__file__)
path = directory + '/selenium-server-standalone-2.28.0.jar'
sub = subprocess.Popen('exec java -jar ' + path,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True)
self.selenium_server = sub
count = 0
while True: # ensure the server is established
try:
self.selenium = selenium("localhost",
4444,
"*chrome",
"http://127.0.0.1:8000/resources/")
self.selenium.start()
break
except socket.error, v:
count += 1
if count == 10:
message = "- Selenium server took to long to establish"
print "\n", v, message
sys.exit()
time.sleep(1)
運行我使用的命令測試:
python -m unittest -v selenium_tests_mod
這引起了:
[Errno 111] Connection refused - Selenium server took to long to establish
所以我知道這是有問題的建立連接,只是沒有爲什麼?
注:當我今天使用Django的測試框架它的工作原理,只是沒有當我嘗試運行它手動運行
編輯:
當我在一個單獨的shell中運行硒服務器它的工作原理
java -jar selenium-server-standalone-2.28.0.jar
所以現在我假定這可能是原因:
sub = subprocess.Popen('exec java -jar ' + path,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True)