Last active
April 5, 2020 08:24
-
-
Save mireshsonkamble/f446c8cae6a9bac5b487b2f6c7dd3dbd to your computer and use it in GitHub Desktop.
CSample.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using OpenQA.Selenium; | |
| using OpenQA.Selenium.Remote; | |
| namespace WebDriverSample | |
| { | |
| public class CSample | |
| { | |
| static void Main(string[] args) | |
| { | |
| IWebDriver driver; | |
| DesiredCapabilities caps = new DesiredCapabilities(); | |
| //Pass User Name and Access Key | |
| caps.SetCapability("browserstack.user", "<USERNAME>"); | |
| caps.SetCapability("browserstack.key", "<ACCESSKEY>"); | |
| //Select OS | |
| caps.SetCapability("os", "Windows"); | |
| caps.SetCapability("os_version", "7"); | |
| //SElect Browser | |
| caps.SetCapability("browser", "Chrome"); | |
| caps.SetCapability("browser_version", "78.0"); | |
| //Local Testing Caps | |
| caps.SetCapability("browserstack.local", "false"); | |
| //Custom Project Name | |
| caps.SetCapability("project", "example"); | |
| //Custom Build Name | |
| caps.SetCapability("buildName", "BSSupport_M"); | |
| //Custom Session Name | |
| caps.SetCapability("name", "example"); | |
| //Generate screenshots at various steps in your test | |
| caps.SetCapability("browserstack.debug", "true"); | |
| //Capture browser console logs at various steps in your test | |
| caps.SetCapability("browserstack.console", "verbose"); | |
| //capture network logs for your test | |
| caps.SetCapability("browserstack.networkLogs", "true"); | |
| //Disable video recording during your test, if Capability is not used default value is true | |
| caps.SetCapability("browserstack.video", "true"); | |
| //Only for Mobile testing, default value is true | |
| //caps.SetCapability("browserstack.appiumLogs", "false"); | |
| //Required if you want to enable selenium logs for your desktop browser tests. | |
| //caps.SetCapability("browserstack.seleniumLogs", "false"); | |
| //Change device orientation, default is portrait | |
| //caps.SetCapability("deviceOrientation", "landscape"); | |
| //Run your Selenium tests in W3C mode. If this is enabled, we assume that your Selenium capabilities are compliant with the W3C-spec. | |
| //Read more here - https://www.w3.org/TR/webdriver/ | |
| //W3C is currently supported on Firefox version 53 and above for Selenium versions: 3.7.0, 3.7.1, 3.8.0, 3.8.1, | |
| //3.9.0, 3.9.1, 3.10.0, 3.11.0, 3.12.0, 3.13.0, 3.14.0, 3.141.0, 3.141.5, 3.141.59, 4.0.0-alpha-1, 4.0.0-alpha-2 | |
| //caps.SetCapability("browserstack.use_w3c", "true"); | |
| //Use this capability to specify the unique Local Testing connection name in your test. | |
| //caps.SetCapability("browserstack.localIdentifier", "RANDONVALUE"); | |
| //Use this capability to run your tests on a custom timezone. | |
| //caps.SetCapability("browserstack.timezone", "NZ"); | |
| //Set the resolution of VM before beginning of your test. | |
| //caps.SetCapability("resolution", "1366x768"); | |
| //Use this capability to set the Selenium WebDriver version in test scripts. | |
| //caps.SetCapability("browserstack.selenium_version", "3.5.2"); | |
| //Use this capability to mask the data sent or retrieved by certain commands. | |
| //Note: You can pass multiple commands in a single array, separated by commas. | |
| //caps.SetCapability("browserstack.maskCommands", "setValues, getValues, setCookies, getCookies"); | |
| //This capability can be used to modify the timeout value. | |
| //caps.SetCapability("browserstack.idleTimeout","300"); | |
| //If you use basic authentication in your test cases, the username and password would be visible in text logs. | |
| //Use this capability to mask those credentials. | |
| //caps.SetCapability("browserstack.maskBasicAuth", "true"); | |
| //Use this capability to specify a custom delay between the execution of Selenium commands. | |
| //caps.SetCapability("browserstack.autoWait", "35"); | |
| //Use this capability to add host entry (/etc/hosts) in remote BrowserStack machine. | |
| //For example, if you use staging.website.com in test cases but do not have a DNS entry for the domain and the public IP, | |
| //you can use this capability to add host entry in the machine. | |
| //caps.SetCapability("browserstack.hosts","<IP_address Domain_name>"); | |
| //IE 11 browser uses cached pages when you navigate using the backward or forward browser buttons. | |
| //You can use this capability to disable the use of cached pages. | |
| //caps.SetCapability("browserstack.bfcache","0"); | |
| //Mobile Specific Capabiltiy | |
| //Use this flag to test on a physical mobile device. | |
| //caps.SetCapability("real_mobile", "true"); | |
| //Required if you want to simulate the custom network condition. | |
| //caps.SetCapability("browserstack.customNetwork","1000"); | |
| //Required if you want to simulate different network conditions. | |
| //caps.SetCapability("browserstack.networkProfile","3g-umts-good"); | |
| //IE/Edge capabilities | |
| //Use this capability to disable flash on Internet Explorer. | |
| //caps.SetCapability("browserstack.ie.noFlash","true"); | |
| //Use this capability to set Internet Explorer Compatibility View. | |
| //caps.SetCapability("browserstack.ie.compatibility","11001"); | |
| //Use this capability to specify the IE WebDriver architecture. | |
| //caps.SetCapability("browserstack.ie.arch","x32"); | |
| //Use this capability to specify the IE WebDriver version. | |
| //caps.SetCapability("browserstack.ie.driver","2.21"); | |
| //Use this capability to enable the popups in IE. | |
| //caps.SetCapability("browserstack.ie.enablePopups","true"); | |
| //Use this capability to enable the popups in Edge | |
| //caps.SetCapability("browserstack.edge.enablePopups","true"); | |
| //Set the capability to ‘True’ while using sendKeys on IE 11 browser. | |
| //caps.SetCapability("browserstack.sendKeys","true"); | |
| //Safari capabilities: | |
| //Safari browser disables pop-ups by default, that is, any action that triggers a popup window is disabled in Safari. | |
| //Use this capability to enable popups in Safari. | |
| //caps.SetCapability("browserstack.safari.enablePopups","true"); | |
| //Use this capability to enable all cookies in Safari. | |
| //caps.SetCapability("browserstack.safari.allowAllCookies","true"); | |
| //Use this capability to specify the Safari WebDriver version. | |
| //caps.SetCapability("browserstack.safari.driver","2.45"); | |
| //Firefox and Gecko driver capabilities: | |
| //Use this capability to specify the version of geckodriver. | |
| //caps.SetCapability("browserstack.geckodriver","0.10.0"); | |
| driver = new RemoteWebDriver( | |
| new Uri("http://hub-cloud.browserstack.com/wd/hub/"), capability | |
| ); | |
| driver.Navigate().GoToUrl("http://www.google.com"); | |
| Console.WriteLine(driver.Title); | |
| IWebElement query = driver.FindElement(By.Name("q")); | |
| query.SendKeys("Browserstack"); | |
| query.Submit(); | |
| Console.WriteLine(driver.Title); | |
| driver.Quit(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment