Created
February 8, 2021 16:47
-
-
Save muditlambda/e2bd37cafc1a38ca31ce5ed7b5d05374 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 actual_url = brow.Geturl; | |
Console.WriteLine("url " + actual_url); | |
// Raise an assert if the URL's match | |
// The URL on which testing is done is "https://www.lambdatest.com" | |
// Whereas the get URL will return "https://www.lambdatest.com/" | |
// Hence the above test will pass | |
Assert.That(actual_url, Is.Not.EqualTo(test_url)); | |
Console.WriteLine("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