-
Notifications
You must be signed in to change notification settings - Fork 3
/
GoogleSearchEngineUsingEdgeBrowser.cs
43 lines (35 loc) · 1.56 KB
/
GoogleSearchEngineUsingEdgeBrowser.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
39
40
41
42
43
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Edge;
namespace Selenium3_7_VisualStudio2017
{
[TestClass]
public class GoogleSearchEngineUsingEdgeBrowser
{
// EdgeDriver full path: @"C:\SeleniumEdgeDriver\MicrosoftWebDriver.exe”
string edgeDriverLocation = @"C:\SeleniumEdgeDriver";
[TestMethod]
public void Shoud_Search_Using_EdgeBrowser()
{
// Initialize the IE Driver
using (var driver = new EdgeDriver(edgeDriverLocation))
{
// 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
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
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");
}
}
}
}