文本框,我想考这个文本框是只读的(无法输入/编辑)。注意:文本框中的值每次都是不同的。
HTML代码:
<input type="text" class="form-control" id="system_lan1_mac" value="00:15:8b:00:5f:8e" disabled="">
我曾尝试使用下面的代码来定位文本框:
def test_a(self):
ip = self.find_by_id('system_lan2_mac')
self.assertFalse(ip.is_enabled())
这不工作 - 我知道is_enabled()是不应该在这方面使用。查找文本框时出现超时错误。如果我将ID更改为常规文本框的ID,测试可以找到它。只要我将其更改为只读ID,就会出现超时错误。
感谢
编辑: find_by_id代码:
def find_by_id(self, setting):
element = self.wait.until(EC.element_to_be_clickable((By.ID, setting)))
return element
WebDriverWait定义:
cls.wait = WebDriverWait(cls.driver, 10)
您的选择器在提供的HTML中使用'id =“system_lan2_mac”'它是'id =“system_lan1_mac”'...'is_enabled()'可以在此上下文中使用 – Andersson
嗨。道歉 - 还有一个system_lan2_mac,该代码不适用于该框。 – Sithling
你在'self.find_by_id()'中使用'WebdriverWait' +'ExpectedConditions'吗?如果是这样,告诉我们这个代码 – Andersson