Webdriver selenium setup with options and features

Using selenium is easy, although I need to run the driver with the correct settings

so for now I just need it to ignore the zoom level

my code is:

public string path = AppDomain.CurrentDomain.BaseDirectory; public IWebDriver WebDriver; var ieD = Path.Combine(path, "bin"); DesiredCapabilities caps = DesiredCapabilities.InternetExplorer(); caps.SetCapability("ignoreZoomSetting", true); 

now my current code only passes the driver path as a parameter

 WebDriver = new InternetExplorerDriver(ieD); 

how can I correctly pass both paths and the path to the drivers?

+4
source share
1 answer

There is an InternetExplorerOptions class for IE options . See the source , which has the AddAdditionalCapability method. However, for your ignoreZoomSetting class already provided a property called IgnoreZoomLevel , so you do not need to set the capabilities.

On the other hand, InternetExplorerDriver has a constructor for both IEDriver and InternetExplorerOptions. A source

 public InternetExplorerDriver(string internetExplorerDriverServerDirectory, InternetExplorerOptions options) 

Here's how you use it:

 var options = new InternetExplorerOptions { EnableNativeEvents = true, // just as an example, you don't need this IgnoreZoomLevel = true }; // alternative // var options = new InternetExplorerOptions(); // options.IgnoreZoomLevel = true; // alternatively, you can add it manually, make name and value are correct options.AddAdditionalCapability("some other capability", true); WebDriver = new InternetExplorerDriver(ieD, options); 
+8
source

Source: https://habr.com/ru/post/1488949/


All Articles