(selenium系列之八)切换

web应用中经常有iframe表单嵌套、跳转不同窗口、弹出警告框、确认框等的情况,就需要切换进去才能操作。

表单切换:driver.switch_to.frame('child_frame')

表单切回:driver.switch_to.parent_frame()

多窗口切换:driver.switch_to.window("new_window_handle")

切换到警告框:driver.switch_to_alert()

接收警告框:driver.switch_to_alert().accept()

解散现有警告框:driver.switch_to_alert().dismiss()

发送文本至警告框:driver.switch_to_alert().send_keys("文本")

返回alert/confirm/prompt中的文字信息: driver.switch_to_alert().text

猜你喜欢

转载自blog.csdn.net/m0_37553368/article/details/81662936