How to use get options method in Selenium?
Please see the following code: var pageSource = driver.
PageSource; I want to add one more line to my code and use it. Driver.Manage().Options.AddArgument("user-agent","Mozilla/5.0");
Driver.PageSource is not a method available to the driver. I want to add the argument so that when the test start it will look like browser is Mozilla. Is this possible?
Using C# or Java you can make use of the AddArgument method on Options which takes the argument, as well as the argument's key-value pair. In your example, you need something like: var options = new Options();. Options.AddArgument("user-agent","Mozilla/5.0");
Options.AddArgument("browser", "Mozilla"); driver.Manage().AddArgument("browser", options);
Alternatively, in C# (as well as the other languages you mentioned), you can use the static SetOptions method, instead of creating a new Options object and calling AddArgument: var options = DesiredCapabilities.Firefox(); options.PageSource() to driver.Manage().Page().Source()
Just to wrap up the other answers. If I'm not mistaken (I'm usually wrong) the following would work.
Manage.AddArgument("user-agent", "MyTestApp"); var pageSource = driver.Manage().
Related Answers
How can we use the Selenium tool with HeadSpin?
Selenium is a tool that is used to automate functional testing. There are two types...
What are 5 Uses of Selenium?
Selenium is a web-automation tool that helps you to test web applications....
Whats the focus of this Selenium Certification Training?
You can learn it in a week. You just have to know the basics about what we...