Adding ChromeOptions for Selenium Webdriver C#

Viewed 9131

From what I understand, the default action of when the Webdriver finds an element is to scroll such that the element is as far up the top of the page as possible. This is an issue because the website I'm working on has a header so every time I try to click on a button, it will instead click on the header. Thus, I want to change the scroll setting so that the element will be at the bottom of the page.

From reading this I was able to find what I wanted to set, however, I'm unable to set the DesiredCapabilites or ChromeOptions when I initialise the ChromeDriver. Could some provide code/steps to do this please?

2 Answers

As far as I know you can't change everything through addarguments. There is a list of what you can do in the Github page. but I have a better solution. you can make your own default settings and save it as a chrome profile. for example I didn't find anything to change homepage with code but this works fine for almost evwerything.

you can use this code :

options.AddArguments( @"user-data -dir=C:\Users\kian\AppData\Local\Google\Chrome\User Data"); options.AddArgument("--profile-directory=Default");

make sure you write the right path and right profile name. to check the profile name you can go to properties. properties

you will see the profile name.

there is a good guide for what else u can do in link.

Related