当前位置:首页 > Web开发 > 正文

e.g: toast = driver.find_element_by_xpath(‘/html/body/div[3

2024-03-31 Web开发

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 以及更早的版本不撑持此属性

定位及措置惩罚惩罚Web页面toast弹框

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/31202.html