51Testing软件测试论坛

标题: 页面弹出的对话框上面的按钮定位不到,求解决! [打印本页]

作者: liudinglong1989    时间: 2017-3-6 17:32
标题: 页面弹出的对话框上面的按钮定位不到,求解决!
页面注销按钮,定位不到元素,不知道怎么搞,求各位大神给指导。
请看附件所图:


作者: 黑盒测试    时间: 2017-3-6 18:27
alert=driver.switch_to_alert()
alert.accept()


作者: 掉渣饼    时间: 2017-3-6 21:26
#接受警告信息
alert = driver.switch_to_alert()
alert.accept()

#提示文本信息打印
alert = driver.switch_to_alert()
print alert.text()

#取消对话框
alert = driver.switch_to_alert()
alert.dismiss()
作者: 掉渣饼    时间: 2017-3-6 21:36
看你的页面源码感觉还有一种可能是你需要先跳出iframe
在browser.find_element_by_class_name("Logout").click()下面加上
browser.switch_to_default_content()
time.sleep(3)
作者: liudinglong1989    时间: 2017-3-7 14:34
黑盒测试 发表于 2017-3-6 18:27
alert=driver.switch_to_alert()
alert.accept()

之前加过这个,但是不行,提示这个 no alert  open ,不知道什么原因。

作者: liudinglong1989    时间: 2017-3-7 14:35
掉渣饼 发表于 2017-3-6 21:26
#接受警告信息
alert = driver.switch_to_alert()
alert.accept()

之前加过这个,但是不行,提示这个 no alert  open ,不知道什么原因。

作者: liudinglong1989    时间: 2017-3-7 14:40
掉渣饼 发表于 2017-3-6 21:36
看你的页面源码感觉还有一种可能是你需要先跳出iframe
在browser.find_element_by_class_name("Logout").c ...

这样还是不行,求大神赐教一下啊。

作者: 掉渣饼    时间: 2017-3-7 16:33
liudinglong1989 发表于 2017-3-7 14:40
这样还是不行,求大神赐教一下啊。

看你写的代码不对啊,你把你标红的部分改成下面的
browser.find_element_by_class_name("Logout").click()
browser.switch_to_default_content()
time.sleep(3)
browser.find_element_by_class_name("aui_state_highlight").click()




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2