Selenium calls Chrome, Firefox, IE, seleniumchrome
In the C # environment, you can use Selenium to call different browsers as follows:
1 IWebDriver driver = null; 2 string Browser =null; 3 if (Browser.Equals("IE")) 4 { 5 InternetExplorerOptions options = new InternetExplorerOptions(); 6 options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; 7 driver = new InternetExplorerDriver(options); 8 9 }10 else if (Browser.Equals("Chrome".ToUpper()))11 {12 driver = new ChromeDriver();13 }14 else15 {16 driver = new FirefoxDriver();17 }
Note:
1. The iedriverserver.exe file must be stored in the bin \ Debug or bin \ releasedirectory of the project when using IE browser.
Use nugetto obtain iedriverserver.exe: Install-Package WebDriver. IEDriverServer. win32
2. When using IE, remove the protection mode of the browser and add the following code.
InternetExplorerOptions options = new InternetExplorerOptions();options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
3. When using the Chrome browser, you must download the chromedriver.exe file in the bin \ Debug or bin \ releasedirectory of the project.
Use nugetto obtain chromedriver.exe: Install-Package Selenium. WebDriver. ChromeDriver