Cro*_*nax 1 python selenium webdriver selenium-webdriver
我正在尝试编写一个自动测试脚本,它将为多个URL执行一组操作.我试图这样做的原因是因为我正在测试一个具有多个功能完全相同的前端接口的Web应用程序,所以如果我可以使用单个测试脚本来运行所有这些,并确保基础知识是按顺序,这可以节省我在代码库更改时的回归测试中的大量时间.
我目前的代码如下:
# initialize the unittest framework
import unittest
# initialize the selenium framework and grab the toolbox for keyboard output
from selenium import selenium, webdriver
# prepare for the usage of remote browsers
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
class Clubmodule(unittest.TestCase):
def setUp(self):
# load up the remote driver and tell it to use Firefox
self.driver = webdriver.Remote(
command_executor="http://127.0.0.1:4444/wd/hub",
desired_capabilities=DesiredCapabilities.FIREFOX)
self.driver.implicitly_wait(3)
def test_010_LoginAdmin(self):
driver = self.driver
# prepare the URL by loading the list from a textfile
with open('urllist.txt', 'r') as f:
urllist = [line.strip() for line in f]
# Go to the /admin url
for url in urllist:
# create the testurl
testurl = str(url) + str("/admin")
# go to the testurl
driver.get("%s" %testurl)
# log in using the admin credentials
def tearDown(self):
# close the browser
self.driver.close()
# make it so!
if __name__ == "__main__":
unittest.main()
Run Code Online (Sandbox Code Playgroud)
当我打印变量时,testurl我得到了正确的函数,但是当我尝试用Python运行我的脚本时,它似乎没有转换driver.get("%s" %testurl)成driver.get("actualurl").
我希望这是一个语法问题,但在尝试了所有的变化之后,我可以想出来,我开始认为这是Webdriver的限制.这可以完成吗?
| 归档时间: |
|
| 查看次数: |
2950 次 |
| 最近记录: |