简体   繁体   English

如何处理 Robot Framework RIDE 中的 Windows 身份验证弹出窗口?

[英]How to handle windows authentication popup in Robot Framework RIDE?

Windows authentication popup of my application appears similar to this app https://www.engprod-charter.net/ I had used below code to handle window authentication popup in selenium using python.我的应用程序的 Windows 身份验证弹出窗口看起来类似于这个应用程序https://www.engprod-charter.net/我曾使用下面的代码使用 python 处理 selenium 中的窗口身份验证弹出窗口。

from selenium import webdriver
import time
import win32com.client

driver=webdriver.Firefox()
driver.maximize_window()
driver.get('https://www.engprod-charter.net/')
shell = win32com.client.Dispatch("WScript.Shell")   
shell.Sendkeys("username")  
shell.Sendkeys("{TAB}")
shell.Sendkeys("password@123") 
time.sleep(5)
shell.Sendkeys("{ENTER}")
time.sleep(2)
driver.quit()

But since I am using python 2.7.12 for Robot Framework, it seems win32com.client is not supported there.但是由于我使用 python 2.7.12 作为 Robot Framework,那里似乎不支持 win32com.client。 I want to know what library I have to use in Robot Framework to handle this scenario.我想知道我必须在 Robot Framework 中使用什么库来处理这种情况。

I am not asking complete solution as this is not the correct approach in stackoverflow, just want a hint what should I try to handle my scenario.我不是在问完整的解决方案,因为这不是 stackoverflow 中的正确方法,只是想提示我应该尝试处理我的场景。 Thanks谢谢

You can achieve your scenario using AutoItLibrary which handles window inputs and similar things.您可以使用处理窗口输入和类似内容的AutoItLibrary实现您的场景。 Basically controlling the entire GUI not just the browser.基本上控制整个 GUI 而不仅仅是浏览器。

First install AutoItLibrary for Robot Framework首先为 Robot Framework 安装 AutoItLibrary

  1. Make sure you have python installed for 32 bit(say python 2.7.6)确保你安装了 32 位的 python(比如 python 2.7.6)
  2. Install pywin32-217.win32-py2.7.exe for 32 bit from here这里为 32 位安装 pywin32-217.win32-py2.7.exe
  3. Download AutoItLibrary and unzip the folder下载AutoItLibrary并解压文件夹
  4. Open command prompt as Administrator and go to downloaded AautoItLibrary folder folder(cd...\\AutoItLibrary-1.1.post1) and then write this command and hit enter python setup.py install以管理员身份打开命令提示符并转到下载的 AautoItLibrary 文件夹文件夹(cd...\\AutoItLibrary-1.1.post1),然后编写此命令并点击输入python setup.py install

Now include AutoItLibrary in Robot Framework现在在 Robot Framework 中包含 AutoItLibrary 在此处输入图片说明 Let us know if this works, I would be interested to know让我们知道这是否有效,我很想知道

This can be easily done using Robot Class in java, which can be run in Robotframework test when required.这可以使用java中的Robot Class轻松完成,需要时可以在Robotframework test中运行。

ie A .jar which will function as handler for the windows authentication pop up.即一个 .jar,它将作为 Windows 身份验证的处理程序弹出。

In RobotFramework you would just need to run a .jar which will handle your pop up.在 RobotFramework 中,您只需要运行一个 .jar 来处理您的弹出窗口。

Just in case you are not used to Java, I can help you with a sample code.以防万一您不习惯 Java,我可以帮助您提供示例代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM