python->selenium->msedgedriver->edge

成坤 李 0 Reputation points
2023-06-02T15:57:03.85+00:00

User's image

User's image

Waht should i do?

Microsoft Edge
Microsoft Edge
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
2,233 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ShiJieLi-MSFT 8,726 Reputation points Microsoft Vendor
    2023-06-05T05:47:43.08+00:00

    Hi @成坤 李,

    This popup is controlled by the setting "Allow Microsoft to save your browsing activity including history, usage, favorites, web content, and other browsing data to personalize Microsoft Edge and Microsoft services like ads, search, shopping and news“. The path is Edge settings --> Privacy, search, and services --> Personalization & advertising. Once it is set ON, there will be no such popup again.

    To achieve it in Python for Selenium tests, you can use the following code:

    from selenium import webdriver
    from selenium.webdriver.edge.options import Options as EdgeOptions
    option = EdgeOptions()
    prefs = {
        'user_experience_metrics': {
            'personalization_data_consent_enabled': True
        }
    }
    option.add_experimental_option('prefs', prefs)
    
    driver = webdriver.Edge(options = option)
    

    Then you won't see this popup in your Selenium test.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    Shijie Li

    2 people found this answer helpful.