Skip to content

Instantly share code, notes, and snippets.

@muditlambda
Created February 8, 2021 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muditlambda/6956c8ba1ed20660875ba56c55fdddb3 to your computer and use it in GitHub Desktop.
Save muditlambda/6956c8ba1ed20660875ba56c55fdddb3 to your computer and use it in GitHub Desktop.
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 substring_title = "lambdaTest";
String site_title = brow.Title;
Console.WriteLine("The site title is " + site_title);
// Raise an assert if the substring LambdaTest is present
Assert.That(site_title, Does.Contain(substring_title).IgnoreCase);
Console.WriteLine("Substring is present, 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