【发布时间】:2018-08-06 13:51:59
【问题描述】:
我正在尝试将一些methods 添加到我经常使用的WebElements。我想出了如何让它工作,但现在我的断言语句失败了。这就是我所拥有的。如何让我的assert 工作?
def is_below(self, above_element):
below = self.location['y']
above = above_element.location['y']
self.assertLess(above, below)
WebElement.is_below = WebElement_is_below
实际上,这就是我想要弄清楚的所有逻辑:
class ModifiedTestCase(TestCase):
def is_below(self, above_element):
below = self.location['y']
above = above_element.location['y']
self.assertLess(above, below)
WebElement.is_below = WebElement_is_below
class SeleniumTest(ModifiedTestCase):
def test_web_page(self):
above_element = self.find_element()
below_element = self.find_element()
below_element.is_below(above_element)
我得到的错误是“WebElement 没有属性 assertIn”。我知道我可以给它传递一个driver 参数,但这会破坏一些简单性。
【问题讨论】:
标签: python python-3.x selenium selenium-webdriver webdriver