简体   繁体   English

如何使用 Java 使用 Selenium WebDriver 处理 Firefox 中的身份验证弹出窗口

[英]How to handle authentication popup in Firefox with Selenium WebDriver using Java

I am trying to create extension for bypassing server authentication, install it on Firefox browser and pass the.xpi file while driver creation so that it gets invoked while login and the server authentication is bypassed.我正在尝试创建用于绕过服务器身份验证的扩展,将其安装在 Firefox 浏览器上,并在创建驱动程序时传递 .xpi 文件,以便在登录时调用它并绕过服务器身份验证。 Facing error while installing the.xpi file on firefox.在 firefox 上安装 .xpi 文件时遇到错误。 Error: "This add on could not be installed because it appears to be corrupt"错误:“无法安装此插件,因为它似乎已损坏”

Steps 1. Created a manifest.json file (Code mentioned below)步骤 1. 创建 manifest.json 文件(代码如下)

{
“name”: “Webrequest API”,
“version”: “1.0”,
“description”: “Extension to handle Authentication window”,
“permissions”: [
“webRequest”,
“webRequestBlocking”,
“”
],
“background”: {
“scripts”: [“webrequest.js”]
},
“manifest_version”: 2
}
  1. Created webrequest.js file.创建 webrequest.js 文件。 Code mentioned below.下面提到的代码。

    var target = “ https://sso.viacomcloud.com/ ”;变种目标=“ https://sso.viacomcloud.com/ ”;

     var myCredentials = { username: “getestone”, password: “V*******” } var pendingRequests = []; // A request has completed. // We can stop worrying about it. function completed(requestDetails) { console.log(“completed: ” + requestDetails.requestId); var index = pendingRequests.indexOf(requestDetails.requestId); if (index > -1) { pendingRequests.splice(index, 1); } } function provideCredentialsSync(requestDetails) { // If we have seen this request before, then // assume our credentials were bad, and give up. if (pendingRequests.indexOf(requestDetails.requestId).= -1) { console:log(“bad credentials for. ” + requestDetails;requestId): return {cancel;true}. } pendingRequests.push(requestDetails;requestId). console:log(“providing credentials for. ” + requestDetails;requestId): return {authCredentials; myCredentials}. } browser.webRequest.onAuthRequired,addListener( provideCredentialsSync: {urls, [target]}; [“blocking”] ). browser.webRequest.onCompleted,addListener( completed: {urls; [target]} );
  2. Created a zip file using 7-zip file manager and renamed the zip file as Ext.xpi使用 7-zip 文件管理器创建了 zip 文件并将 zip 文件重命名为 Ext.xpi

  3. Opened about:config on firefox (verson 70) and changed xpiextensionsignrequired to 'False'打开关于:firefox(版本 70)上的配置并将 xpiextensionsignrequired 更改为“False”

  4. Opened about:addons on firefox.打开:firefox 上的插件。 Selected 'install extension from a file'.选择“从文件安装扩展”。 Select the Ext.xpi created in step 4 above. Select 在上面的步骤 4 中创建的 Ext.xpi。

  5. I get the following error: ” this add on could not be installed because it appears to be corrupt.”我收到以下错误:“无法安装此插件,因为它似乎已损坏。” instead of getting the Install option on Firefox browser.而不是在 Firefox 浏览器上获得安装选项。

Please help @SubjectiveReality请帮助@SubjectiveReality

Try using the class "Robot" and send keys in case you are looking for a quick solution.如果您正在寻找快速解决方案,请尝试使用 class“机器人”并发送密钥。

Robot rb= new Robot();机器人 rb= new Robot(); rb.Keypress()..... rb.Keypress() .....

暂无
暂无

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

相关问题 如何使用Java处理Selenium中的浏览器通知弹出窗口? - How to handle the browser notification popup in selenium using java? 我正在使用带有Java和firefox 45.0.1的Selenium Webdriver 2.53.1,并尝试使用具有隐藏类的linktext(打开弹出窗口)登录 - I am using selenium webdriver 2.53.1 with java and firefox 45.0.1 and try to login with linktext(open popup window) with hidden class 如何使用Selenium Webdriver处理Javascript单击? - How to handle Javascript click by using selenium Webdriver? 使用 Selenium Webdriver 和 Java 处理网页对话框窗口上的下拉菜单 - Handle dropdown on Webpage Dialog window using Selenium Webdriver and Java 无法使用Java在Selenium Webdriver中单击弹出按钮 - Unable to click on a popup button in selenium webdriver with java Selenium-WebDriver 如何使用 javascript 和 firefox 浏览器突出显示元素 - Selenium-WebDriver how to highlight element using javascript and firefox browser 如何使用python处理Selenium Webdriver中基于Web的弹出窗口 - How to Handle web based pop up in selenium webdriver using python 如何使用Selenium Webdriver处理HTML Shadow Dom? - How to handle html shadow dom using selenium webdriver? 如何使用Python / Selenium webdriver处理Angularjs / Javascript下拉列表? - How to handle Angularjs / Javascript dropdown using Python / Selenium webdriver? 如何在Java中使用Selenium访问弹出元素 - How to access popup elements using Selenium in Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM