RemoteWebDriver is a class . it implements WebDriver interface.
It is used to execute test scripts via the RemoteWebDriver server on a remote machine.
using System; using OpenQA.Selenium; using OpenQA.Selenium.Remote; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Chrome; using OpenQA.Selenium.IE; using System.Threading; using System.Drawing; namespace Test { class Program { static void Main(string[] args) { RemoteWebDriver driver; //FIREFOX example testing with version 70 on Linux FirefoxOptions Options = new FirefoxOptions(); // Options.BrowserExecutableLocation = "C:\\Program Files (x86)\\Mozilla Firefox\\firefox70\\firefox.exe"; // WINDOWS Options.BrowserExecutableLocation = "/home/ubuntu/Downloads/firefox70/firefox"; // LINUX // Options.PlatformName = "windows"; // exclude for linux Options.AddAdditionalCapability("platform", "LINUX", true); // Supported values: "VISTA" (Windows 7), "WIN8" (Windows 8), "WIN8_1" (windows 8.1), "WIN10" (Windows 10), "LINUX" (Linux) Options.AddAdditionalCapability("version", "70", true); // for Chrome only, you can specify version=latest or the real version number like version=74. For Firefox and IE you must always specify the version number. Options.AddAdditionalCapability("gridlasticUser", USERNAME, true); Options.AddAdditionalCapability("gridlasticKey", ACCESS_KEY, true); Options.AddAdditionalCapability("video", "True", true); driver = new RemoteWebDriver( new Uri("http://YOUR_GRIDLASTIC_SUBDOMAIN.gridlastic.com:80/wd/hub/"), Options.ToCapabilities(), TimeSpan.FromSeconds(600));// NOTE: connection timeout of 600 seconds or more required for time to launch grid nodes if non are available. try { // driver.Manage().Window.Maximize(); // WINDOWS, DO NOT WORK FOR LINUX/firefox. If Linux/firefox set window size, max 1920x1080, like driver.Manage().Window.Size = new Size(1920, 1080); driver.Manage().Window.Size = new Size(1920, 1080); // LINUX/firefox driver.Navigate().GoToUrl("https://www.google.com/ncr"); IWebElement query = driver.FindElement(By.Name("q")); query.SendKeys("webdriver"); query.Submit(); } finally { Console.WriteLine("Video: " + VIDEO_URL + driver.SessionId); driver.Quit(); } } } }
Example for Selenium version 3.13.0 and below
// Download the C# webdriver at https://www.nuget.org/packages/Selenium.WebDriver using System; using OpenQA.Selenium; using OpenQA.Selenium.Remote; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Chrome; using OpenQA.Selenium.IE; using System.Threading; using System.Drawing; namespace Test { class Program { static void Main(string[] args) { RemoteWebDriver driver; DesiredCapabilities capability = DesiredCapabilities.Chrome(); capability.SetCapability("platform", "WIN10"); // Supported values: "VISTA" (Windows 7), "WIN8" (Windows 8), "WIN8_1" (windows 8.1), "WIN10" (Windows 10), "LINUX" (Linux) //capability.SetCapability("platformName", "windows"); // (selenium version 3.5.3+) capability.SetCapability("version", "latest"); // for Chrome only, you can specify version=latest or the real version number like version=74. For Firefox and IE you must always specify the version number. capability.SetCapability("gridlasticUser", USERNAME); capability.SetCapability("gridlasticKey", ACCESS_KEY); capability.SetCapability("video", "True"); //capability.SetCapability("firefox_binary", @"C:\Program Files (x86)\Mozilla Firefox\firefox70\firefox.exe"); // For firefox testing specify binary location (selenium version 3.5.3+) driver = new RemoteWebDriver( new Uri("http://YOUR_GRIDLASTIC_SUBDOMAIN.gridlastic.com:80/wd/hub/"), capability, TimeSpan.FromSeconds(600));// NOTE: connection timeout of 600 seconds or more required for time to launch grid nodes if non are available. try { driver.Manage().Window.Maximize(); // WINDOWS, DO NOT WORK FOR LINUX/firefox. If Linux/firefox set window size, max 1920x1080, like driver.Manage().Window.Size = new Size(1920, 1080); // driver.Manage().Window.Size = new Size(1920, 1080); // LINUX/firefox driver.Navigate().GoToUrl("https://www.google.com/ncr"); IWebElement query = driver.FindElement(By.Name("q")); query.SendKeys("webdriver"); query.Submit(); } finally { Console.WriteLine("Video: " + VIDEO_URL + driver.SessionId); driver.Quit(); } } } }=================
Selenium C# Firefox Example
using System; using OpenQA.Selenium; using OpenQA.Selenium.Remote; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Chrome; using OpenQA.Selenium.IE; using System.Threading; using System.Drawing; namespace Test { class Program { static void Main(string[] args) { RemoteWebDriver driver; //FIREFOX example testing with version 70 on Linux FirefoxOptions Options = new FirefoxOptions(); // Options.BrowserExecutableLocation = "C:\\Program Files (x86)\\Mozilla Firefox\\firefox70\\firefox.exe"; // WINDOWS Options.BrowserExecutableLocation = "/home/ubuntu/Downloads/firefox70/firefox"; // LINUX // Options.PlatformName = "windows"; // exclude for linux Options.AddAdditionalCapability("platform", "LINUX", true); // Supported values: "VISTA" (Windows 7), "WIN8" (Windows 8), "WIN8_1" (windows 8.1), "WIN10" (Windows 10), "LINUX" (Linux) Options.AddAdditionalCapability("version", "70", true); // for Chrome only, you can specify version=latest or the real version number like version=74. For Firefox and IE you must always specify the version number. Options.AddAdditionalCapability("gridlasticUser", USERNAME, true); Options.AddAdditionalCapability("gridlasticKey", ACCESS_KEY, true); Options.AddAdditionalCapability("video", "True", true); driver = new RemoteWebDriver( new Uri("http://YOUR_GRIDLASTIC_SUBDOMAIN.gridlastic.com:80/wd/hub/"), Options.ToCapabilities(), TimeSpan.FromSeconds(600));// NOTE: connection timeout of 600 seconds or more required for time to launch grid nodes if non are available. try { // driver.Manage().Window.Maximize(); // WINDOWS, DO NOT WORK FOR LINUX/firefox. If Linux/firefox set window size, max 1920x1080, like driver.Manage().Window.Size = new Size(1920, 1080); driver.Manage().Window.Size = new Size(1920, 1080); // LINUX/firefox driver.Navigate().GoToUrl("https://www.google.com/ncr"); IWebElement query = driver.FindElement(By.Name("q")); query.SendKeys("webdriver"); query.Submit(); } finally { Console.WriteLine("Video: " + VIDEO_URL + driver.SessionId); driver.Quit(); } } } }
No comments:
Post a Comment