-
Notifications
You must be signed in to change notification settings - Fork 0
/
GoogleSearchTests.cs
60 lines (52 loc) · 1.68 KB
/
GoogleSearchTests.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using Google.PageObjects;
namespace SeleniumWebdriver
{
[TestFixture]
public class GoogleSearchTests
{
private IWebDriver driver;
[SetUp]
public void SetupTest()
{
ChromeOptions options = new ChromeOptions();
options.AddArgument("--no-sandbox"); // Bypass OS security model, to run in Docker
options.AddArgument("--headless");
driver = new ChromeDriver(options);
}
[TearDown]
public void TeardownTest()
{
try
{
driver.Quit();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
}
[Test, Property("Requirement", "XT-9")]
public void BasicTextSearch()
{
HomePage homePage = new HomePage(driver).Open();
//Assert.AreEqual("Google", homePage.PageTitle());
SearchResultsPage searchResultsPage = homePage.Search("Selenium OpenQA");
//searchResultsPage.results.first
Assert.IsTrue(searchResultsPage.Contains("www.selenium.dev"));
}
[Test, Property("Requirement", "XT-9")]
public void BasicTextSearchNoPOM()
{
driver.Navigate().GoToUrl("http://www.google.com/");
Assert.AreEqual("Google", driver.Title);
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Selenium OpenQA");
query.Submit();
Assert.IsTrue(driver.PageSource.Contains("www.selenium.dev"));
}
}
}