Created
April 1, 2014 20:42
-
-
Save stevecooperorg/9922745 to your computer and use it in GitHub Desktop.
Using initialized variables
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 Microsoft.VisualStudio.TestTools.UnitTesting; | |
using OpenQA.Selenium; | |
using OpenQA.Selenium.Chrome; | |
namespace GoogleTest | |
{ | |
[TestClass] | |
public class SharingVariableTest | |
{ | |
private string homePageUrl; | |
[TestInitialize] | |
public void Initialize() | |
{ | |
this.homePageUrl = "http://www.google.co.uk"; ; | |
} | |
[TestMethod] | |
public void TestThatUsesInitializedVariable() | |
{ | |
IWebDriver driver = new ChromeDriver(); | |
//Notice navigation is slightly different than the Java version | |
//This is because 'get' is a keyword in C# | |
driver.Navigate().GoToUrl(this.homePageUrl); | |
// Find the text input element by its name | |
IWebElement query = driver.FindElement(By.Name("q")); | |
// Enter something to search for | |
query.SendKeys("Cheese"); | |
// Now submit the form. WebDriver will find the form for us from the element | |
query.Submit(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment