我正在使用Python编写使用selenium webdriver的测试。我想知道的是,当我将一个链接存储为一个变量并用type()
进行检查时,为什么它在使用时返回false检验.isclass().
相关代码:
salesForceLink = findCss(sel, "div.row:nth-child(1) > div:nth-child(1) >
div:nth-child(1) > div:nth-child(3) > a:nth-child(1)")
print(type(salesForceLink))
我得到了结果
<class 'selenium.webdriver.firefox.webelement.FirefoxWebElement'>
然后我用
print(inspect.isclass(salesForceLink))
这导致False
我错过了什么?为什么返回false?在
编辑:
我最终需要一个if语句来检查变量salesForceLink
是否是“something”。在
示例:
^{pr2}$
根据我的编辑,这是我发现的一个解决办法。在
编辑:根据下面的第一条评论,我发现虽然这句话等同于真的,但实际上我只是做了双倍的工作。我的工作解决方案是使用自定义包装函数的两行代码。第二个验证链接后的文本。在
^{pr2}$对于感兴趣的用户,自定义函数如下:
以及
print debug函数只接受bool并打印true或false。 所有看起来像G.error或G.debug的变量都是代理全局变量,它们存储在一个空类中,以便在我的许多测试中使用。在
我希望这有帮助。在
我是一个人。人类是一个物种。在
这并不意味着我是一个物种。在
^{pr2}$salesForceLink
是FirefoxWebElement
。FirefoxWebElement
是一个类。在这并不意味着
salesForceLink
是一个类。在相关问题 更多 >
编程相关推荐