Created
February 8, 2021 16:58
-
-
Save muditlambda/1774e577464de0ce59e779fc866a3d51 to your computer and use it in GitHub Desktop.
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 NUnit.Framework; | |
using OpenQA.Selenium; | |
using OpenQA.Selenium.Chrome; | |
using OpenQA.Selenium.Firefox; | |
using OpenQA.Selenium.IE; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Assert_Demo | |
{ | |
public class Browser_ops | |
{ | |
IWebDriver webDriver; | |
public void Init_Browser() | |
{ | |
webDriver = new ChromeDriver(); | |
webDriver.Manage().Window.Maximize(); | |
} | |
public string Title | |
{ | |
get { return webDriver.Title; } | |
} | |
public void Goto(string url) | |
{ | |
webDriver.Url = url; | |
} | |
public string Geturl | |
{ | |
get { return webDriver.Url; } | |
} | |
public void Close() | |
{ | |
webDriver.Quit(); | |
} | |
public IWebDriver getDriver | |
{ | |
get { return webDriver; } | |
} | |
} | |
class Assert_Demo_1 | |
{ | |
Browser_ops brow = new Browser_ops(); | |
String test_url = "https://www.lambdatest.com"; | |
[SetUp] | |
public void start_Browser() | |
{ | |
brow.Init_Browser(); | |
} | |
[Test] | |
public void test_asserturl() | |
{ | |
brow.Goto(test_url); | |
System.Threading.Thread.Sleep(4000); | |
String expected_title = "Cross Browser Testing Tools | Free Automated Website Testing | LambdaTest"; | |
String site_title = brow.Title; | |
Console.WriteLine("The site title is " + site_title); | |
// Raise an assert if the strings i.e. site titles do not match | |
Assert.That(expected_title, Is.EqualTo(site_title)); | |
Console.WriteLine("String Constraint Test Passed"); | |
/* Perform wait to check the output */ | |
System.Threading.Thread.Sleep(2000); | |
} | |
[TearDown] | |
public void close_Browser() | |
{ | |
brow.Close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment