Changing the user agent using selenium webdriver in Java

后端 未结 3 1503
再見小時候
再見小時候 2021-02-06 11:36

Can someone pls tell me how to switch the user agent using webdriver in Java? I tried below, but getting errors.

FirefoxProfile ffp = new FirefoxProfile(); 
ffp.         


        
3条回答
  •  [愿得一人]
    2021-02-06 12:03

    DesiredCapabilities would help you to change user agent.

    You can achieve this by calling these methods:

    • setBrowserName(java.lang.String browserName)
    • setPlatform(Platform platform)
    • setVersion(java.lang.String version)

    Or

    • static DesiredCapabilities chrome()
    • static DesiredCapabilities firefox()
    • static DesiredCapabilities iphone()
    • ...

    More here.

提交回复
热议问题