Selenium 弹出窗口 [英] Pop Up Window with Selenium

查看:44
本文介绍了Selenium 弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个脚本,可以登录我公司的 wiki,访问页面,然后选择页面上提供的下载到 pdf 选项.然而,当这个选项被选中时,这个对话框

I currently have a script that will log on to my company's wiki, visit a page, and select a download to pdf option available on the page. However, when this option is chosen, this dialogue box

弹出要求我告诉 Firefox 如何处理它.我只需要硒进行交互并点击确定"按钮.

pops up asking me to tell Firefox what to do with it. I just need selenium to interact and hit the "ok" button.

我不知道如何检查这个窗口的元素,我需要指导.任何文档都有帮助.

I'm not sure how to inspect this window for elements, and am need of direction. Any documentation helps.

from splinter import Browser
browser = Browser()
browser.visit('https://company.wiki.com')
browser.find_by_id('login-link').click()
browser.fill('os_username', 'user')
browser.fill('os_password', 'pass')
browser.find_by_name('login').click()
browser.visit('https://pageoncompany.wiki.com')
browser.find_by_xpath('//*[@id="navigation"]/ul/li[4]').click()
browser.find_by_id('action-export-pdf-link').click()

推荐答案

我能够通过网络浏览器设置首选项,然后调用我的个人资料:

I was able to set the preferences through the web browser, then call my profile:

browser = Browser('firefox', profile=r'C:\Users\craab\AppData\Roaming\Mozilla\Firefox\Profiles\0lot9hun.default')

这篇关于Selenium 弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆