如何使用 C# 让 Selenium 在 PDF 下载页面上单击“打开”并处理 iframe 选择?

How can I make Selenium click 'Open' on a PDF download page using C# and handle the iframe selection?

提问人:arunkumar-js25 提问时间:5/21/2023 最后编辑:James Zarunkumar-js25 更新时间:5/21/2023 访问量:57

问:

无法使用 C# selenium 单击在 pdf 下载页面中打开。如何让驱动者看懂iframe并做出选择?

PDF下载页面

enter image description here

我试过的硒代码:

   driver.SwitchTo().Window(driver.WindowHandles.Last());
   driver.SwitchTo().Frame(0);
   driver.FindElement(By.LinkText("Open")).Click();

面对这个问题:

enter image description here

C# selenium-webdriver 浏览器自动化 chrome-web-driver

评论


答:

0赞 K J 5/21/2023 #1

当您的案例中有一个子框架要求输入密码,但您在父框架中处于活动状态时,您将看不到更改,也无法访问 PDF 查看器内容,您只能更改自己的环境

enter image description here

您的图像的奇怪之处在于应该有一个模式密码请求来打开受保护的 PDF。

enter image description here