0

This code was working fine, but when switched to firefox from chrome now this is giving me error.

Please help me to find whats the solution

FirefoxOptions options = new FirefoxOptions();
        options.addArguments("--incognito");
        options.addArguments("start-maximized");
//        options.addArguments("--user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac\n" + "OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53");
        options.addArguments("--user-agent=Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36");
        capabilities.setCapability(FirefoxOptions(capabilities), options);
        System.setProperty("webdriver.gecko.driver","/Users/abcd/Downloads/geckodriver");
        WebDriver driver = null;

Please help ....

PaNkit
  • 1
  • 3

1 Answers1

0

I can sense several issues:

  • driver.manage().window().maximize();

  • to browse incognito with Firefox use

    from selenium.webdriver.firefox.options import Options

    options = Options() options.add_argument("-private")

    or see: Python/Selenium incognito/private mode

  • adjusting the user agent is more difficult: https://stackoverflow.com/a/42171906/8291949

    Basically, there is an about:config option general.useragent.override, which you can specify in the user.js file in the profile folder with a line like:

    user_pref("general.useragent.extra.firefox", "Mozilla/5.0 AppleWebKit/537.36…")
    

    And than use capabilities to use the profile. Regarding capabilities see: Can't open browser with Selenium after Firefox update

wp78de
  • 18,207
  • 7
  • 43
  • 71