0
我试图使WebDriver实例通用。我创建了一个小的Python文件来实例化的webdriver浏览器没有在Python中使用Selenium启动
这里是我的代码
#Driver.py
from selenium import webdriver
Instance = None
def Initialize():
global Instance
Instance = webdriver.Chrome("C:\\mystuff\\Browser\\chromedriver.exe")
Instance.implicitly_wait(5)
return Instance
def CloseDriver():
global Instance
Instance.quit()
这是正在使用Commonfunctions.py
import Driver
class LoginPage:
@staticmethod
def GoToURL(url):
print "In GoTo URL"
Driver.Instance.get(url)
最后我测试文件
import unittest
import Driver
from CommonFunctions import LoginPage
class LoginTest(unittest.TestCase):
def setUp(self):
Driver.Initialize()
def testUserCanLogin(self):
LoginPage.GoToURL("http://www.gmail.com")
当我尝试执行此操作时没有错误,我收到消息“在PyCharm控制台中使用exit(0)完成进程”。但是,浏览器从未启动。 如果我尝试在一个块中完成,那么浏览器会顺利启动。
我想创建一个简单的框架,这是我的第一步。如果您有任何其他建议,请指导我。
谢谢!
具有u安装壁虎驱动程序?尝试安装它。那么它可能工作! – rhea
你如何进行测试?你使用了什么命令 –