Last active
June 30, 2018 19:24
-
-
Save nadvolod/b1d183f71e5df9a7edcf to your computer and use it in GitHub Desktop.
A Selenium Webdriver C# test that is ready to be ran in parallel mode in BrowserStack's cloud.
This file contains 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 NUnit.Framework; | |
using OpenQA.Selenium; | |
using OpenQA.Selenium.Remote; | |
namespace ParallelTestingBrowserStack | |
{ | |
[TestFixture] | |
[Parallelizable] | |
public class BrowserstackTest1 | |
{ | |
private IWebDriver _driver; | |
[SetUp] | |
public void Init() | |
{ | |
DesiredCapabilities capability = DesiredCapabilities.Firefox(); | |
capability.SetCapability("browserstack.user", Environment.GetEnvironmentVariable("BROWSERSTACK_USER", EnvironmentVariableTarget.User)); | |
capability.SetCapability("browserstack.key", Environment.GetEnvironmentVariable("BROWSERSTACK_KEY", EnvironmentVariableTarget.User)); | |
capability.SetCapability("browser", "Safari"); | |
capability.SetCapability("browser_version", "5.1"); | |
capability.SetCapability("os", "OS X"); | |
capability.SetCapability("os_version", "Snow Leopard"); | |
capability.SetCapability("resolution", "1024x768"); | |
_driver = new RemoteWebDriver( | |
new Uri("http://hub.browserstack.com/wd/hub/"), capability | |
); | |
} | |
[Test] | |
public void BrowserStackTest01() | |
{ | |
_driver.Navigate().GoToUrl("http://www.qtptutorial.net/automation-practice"); | |
_driver.Manage().Window.Maximize(); | |
_driver.FindElement(By.Id("idExample")).Click(); | |
var elementCheck = _driver.FindElement(By.XPath("//p[contains(text(),'Button success')]")).Displayed; | |
Assert.IsTrue(elementCheck, "Element was not present"); | |
} | |
[TearDown] | |
public void Cleanup() | |
{ | |
_driver.Quit(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment