获取confirm弹框,这里的方法是针对原生js调用confirm弹框
#获取confirm弹框,这里的方法是针对原生js调用confirm弹框
def get_handleconfirm(self,driver):
try:
# 获取弹框
alert = driver.switch_to_alert()
self.my_sleep(2)
alert_txt = alert.text
# 点击确定按钮
alert.accept()
return alert_txt
except Exception as e:
log1.error('定位confirm弹窗的删除弹框,定位失败')
log1.error(e)
调用饿了么组件,需要使用以下方法获取第一个confirm,无法定位到第二个删除按钮对应的删除功能
camera_i_del_popconfirm=["class","el-popover"]
camera_i_del_popconfirm0=self.find_element(camera_i_del_popconfirm)
# a=[]
# for i in camera_i_del_popconfirm0:
# a.append(i)
#
# print(1111)
# print(len(a))
# print(a)
# print(2222)
# print(camera_i_del_popconfirm0)
camera_i_isdel=camera_i_del_popconfirm0.find_element_by_xpath('//div/div/button[2]')
# print(3333)
print(camera_i_isdel)
self.click_selector(camera_i_del_btn)
try:
self.click_el(camera_i_isdel)
except Exception as e:
print('没有找到confirm确定元素')
print(e)
以下是调用饿了么组件的代码