文本框,我想考這個文本框是隻讀的(無法輸入/編輯)。注意:文本框中的值每次都是不同的。
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