【发布时间】:2023-03-22 03:59:01
【问题描述】:
我在弄清楚如何取出硒条中不需要的东西并将其打包成可以从另一个脚本中调用它的方式时遇到了一些麻烦。我无法理解发生了什么这个,因为我不知道单元测试部分的来源......理想情况下,如果我可以将它分成一个我可以称之为的函数,这将是一个想法,感谢您的任何建议。
(而且,是的,我确实需要硒,我请您不要建议替代品,因为我将在很多事情上使用硒,所以我需要弄清楚这一点)
这只是一个基本的演示脚本:
from selenium import selenium
import unittest
class TestGoogle(unittest.TestCase):
def setUp(self):
self.selenium = selenium("localhost", \
4444, "*firefox", "http://www.bing.com")
self.selenium.start()
def test_google(self):
sel = self.selenium
sel.open("http://www.google.com/webhp")
sel.type("q", "hello world")
sel.click("btnG")
sel.wait_for_page_to_load(5000)
self.assertEqual("hello world - Google Search", sel.get_title())
def tearDown(self):
self.selenium.stop()
if __name__ == "__main__":
unittest.main()
【问题讨论】:
-
哦,我刚刚找到了这个:coreygoldberg.blogspot.com/2009/09/… 这似乎是我正在寻找的东西,我会留下这个,因为关于这个主题的内容并不多,我可以找到
标签: python unit-testing selenium