-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGoogleSearchEngineUsingChrome.cs
38 lines (31 loc) · 1.3 KB
/
GoogleSearchEngineUsingChrome.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Chrome;
namespace Selenium3_7_VisualStudio2017
{
[TestClass]
public class GoogleSearchEngineUsingChrome
{
[TestMethod]
public void Shoud_Search_Using_Chrome()
{
// Initialize the Chrome Driver
using (var driver = new ChromeDriver())
{
// 1. Maximize the browser
driver.Manage().Window.Maximize();
// 2. Go to the "Google" homepage
driver.Navigate().GoToUrl("http://www.google.com");
// 3. Find the search textbox (by ID) on the homepage
var searchBox = driver.FindElementById("lst-ib");
// 4. Enter the text (to search for) in the textbox
searchBox.SendKeys("Automation using selenium 3.0 in C#");
// 5. Find the search button (by Name) on the homepage
var searchButton = driver.FindElementByName("btnK");
// 6. Click "Submit" to start the search
searchButton.Submit();
// 7. Find the "Id" of the "Div" containing results stats, just before the results table.
var searchResults = driver.FindElementById("resultStats");
}
}
}
}