简体   繁体   English

使用 Python Selenium 打开 EDGE Chromium

[英]Opening EDGE Chromium using Python Selenium

In order to perform the testing I have to open the Chromium Browser.为了执行测试,我必须打开 Chromium 浏览器。 But When i use但是当我使用

driver = webdriver.Edge('msedgedriver.exe')
driver.get('https://xxx.service-now.com/')

it is taking me to the sign-in page.它带我进入登录页面。

But when i normally open 'xxx.service-now.com' it takes windows authentication and takes me to the service-now page directly.但是当我通常打开“xxx.service-now.com”时,它需要 windows 身份验证并直接将我带到 service-now 页面。

This is my normal Chromium Window这是我的普通 Chromium Window 这是我正常的 Chromium 窗口

and this is my Chromium Window when i am opening using Selenium这是我使用 Selenium 打开时的 Chromium Window 我使用 Selenium 打开时的 Chromium Window

I want to open the normal Chromium using selenium, as it will automatically sign me in.我想使用 selenium 打开普通的 Chromium,因为它会自动让我登录。

Your help will be appreciated.您的帮助将不胜感激。

After doing some experiments i got the answer.在做了一些实验后,我得到了答案。

import selenium, getpass
from selenium import webdriver 
from msedge.selenium_tools import Edge, EdgeOptions

user = getpass.getuser()

options = EdgeOptions()
options.use_chromium = True
options.add_argument("user-data-dir=C:\\Users\\" + user + "\\AppData\\Local\\Microsoft\\Edge\\User Data")
driver = Edge('msedgedriver.exe',options = options)
driver.get('https://xxx.service-now.com/')

This has resolved my issue.这解决了我的问题。

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

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