0
    self.options.add_argument("--headless")
    self.options.add_argument('--no-sandbox')
    self.options.add_argument("disable-infobars")
    # self.options.add_argument('--start-maximized')
    # self.options.add_argument('--start-fullscreen')
    self.options.add_argument('--single-process')
    self.options.add_argument('--disable-dev-shm-usage')
    self.options.add_argument(
        '--disable-blink-features=AutomationControlled')
    self.options.add_experimental_option('useAutomationExtension', False)
    self.options.add_experimental_option("excludeSwitches",
                                         ["enable-automation"])
    self.options.add_argument("log-level=3")
    # self.options.add_argument("--incognito")
    
    self.options.add_argument(
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36'
    )
    

    # Change chrome driver path accordingly
    self.driver = webdriver.Chrome(
        executable_path="B:\mydriver\Resources\chromedriver.exe",
        chrome_options=self.options,
    )
    self.driver.set_window_size(1400, 920)
    self.waitdriver = WebDriverWait(self.driver, 10)
    self.locators = Locators()
    self.driver.get('https://www.facebook.com')
    self.driver.save_screenshot(ROOT_DIR + r"\Temp\Debug\Error1.PNG")
    a = self.driver.execute_script("return navigator.userAgent")
    print(a)
>>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/96.0.4643.0 Safari/537.36

Its not same what i provided to it.I tried to change other user-agents but seems same problem wit it. I am using binary files of chromium.

jay kishan
  • 82
  • 1
  • 7
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 06 '21 at 21:25

1 Answers1

0
self.options.add_argument('user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36')

Solved by Adding user-agent before the useragent. You can check here for much more browser agent.To just rotate then using random.

jay kishan
  • 82
  • 1
  • 7