what?
在Selenium項目中,對頁面做出修改之后,彈出消息提示框,也就是toast。
toast,Web頁面的消息提示框,動畫出現,彈出一段時間后自動消失。e.g.

why?
在實際項目中,用例的失敗與否可以借助toast的屬性來斷言,所以需要定位toast,並且獲取其屬性。
how?
1.定位toast位置
解決辦法如下:


2.獲取toast屬性
介紹selenium.webdriver中get_attribute的用法
"Gets the given attribute or property of the element"源碼的備注
get_attribute不能以webdriver類對象引用它,要用頁面位置。
e.g:
toast = driver.find_element_by_xpath('/html/body/div[3]/div')
text = toast.get_attribute('textContent')
textContent是標簽的HTML DOM 屬性,代表文本內容,類似的還有 className,nodeValue。
注:Internet Explorer 8 以及更早的版本不支持此屬性
