How to use DriverContext method of Ocaramba.Tests.NUnitExtentReports.ProjectTestBase class

Best Ocaramba code snippet using Ocaramba.Tests.NUnitExtentReports.ProjectTestBase.DriverContext

HerokuappTestsNUnit.cs

Source:HerokuappTestsNUnit.cs Github

copy

Full Screen

...34 public void BasicAuthTest()35 {36 const string ExpectedCongratulationsInfo = "Congratulations! You must have the proper credentials.";37 var basicAuthPage =38 new InternetPage(this.DriverContext).OpenHomePageWithUserCredentials().GoToBasicAuthPage();39 test.Info("Verifying congratulations info, expected: " + ExpectedCongratulationsInfo);40 Verify.That(41 this.DriverContext,42 () =>43 Assert.AreEqual(44 ExpectedCongratulationsInfo,45 basicAuthPage.GetCongratulationsInfo));46 }47 [Test]48 public void MultipleWindowsTest()49 {50 const string PageTitle = "New Window";51 var newWindowPage = new InternetPage(this.DriverContext)52 .OpenHomePage()53 .GoToMultipleWindowsPage()54 .OpenNewWindowPage();55 test.Info("Verifying page title, expected: " + PageTitle);56 Assert.True(newWindowPage.IsPageTile(PageTitle), "wrong page title, should be {0}", PageTitle);57 test.Info("Verifying H3 header text displayd on te page, expected: " + PageTitle);58 Assert.True(newWindowPage.IsNewWindowH3TextVisible(PageTitle), "text is not equal to {0}", PageTitle);59 }60 [Test]61 public void NestedFramesTest()62 {63 const string ExpectedLeftFrameText = "LEFT";64 const string ExpectedMiddleFrameText = "MIDDLE";65 const string ExpectedRightFrameText = "RIGHT";66 const string ExpectedBottomFrameText = "BOTTOM";67 var nestedFramesPage = new InternetPage(this.DriverContext)68 .OpenHomePage()69 .GoToNestedFramesPage()70 .SwitchToFrame("frame-top");71 nestedFramesPage.SwitchToFrame("frame-left");72 test.Info("Verifying text displayed in left frame, expected: " + ExpectedLeftFrameText);73 Assert.AreEqual(ExpectedLeftFrameText, nestedFramesPage.LeftBody);74 nestedFramesPage.SwitchToParentFrame().SwitchToFrame("frame-middle");75 test.Info("Verifying text displayed in middle frame, expected: " + ExpectedMiddleFrameText);76 Assert.AreEqual(ExpectedMiddleFrameText, nestedFramesPage.MiddleBody);77 nestedFramesPage.SwitchToParentFrame().SwitchToFrame("frame-right");78 test.Info("Verifying text displayed in right frame, expected: " + ExpectedRightFrameText);79 Assert.AreEqual(ExpectedRightFrameText, nestedFramesPage.RightBody);80 nestedFramesPage.ReturnToDefaultContent().SwitchToFrame("frame-bottom");81 test.Info("Verifying text displayed in bottom frame, expected: " + ExpectedBottomFrameText);82 Assert.AreEqual(ExpectedBottomFrameText, nestedFramesPage.BottomBody);83 }84 [Test]85 public void SetAttributeTest()86 {87 const string PageHeader = "Broken Images";88 var internetPage = new InternetPage(this.DriverContext)89 .OpenHomePage();90 internetPage.ChangeBasicAuthLink("/broken_images");91 internetPage.BasicAuthLinkClick();92 var brokenImagesPage = new BrokenImagesPage(this.DriverContext);93 test.Info("Verifying page header, expected: " + PageHeader);94 Assert.True(brokenImagesPage.IsPageHeaderElementEqualsToExpected(PageHeader), "Page header element is not equal to expected " + PageHeader);95 }96 [Test]97 public void TablesTest()98 {99 const string ExpectedSurname = "Smith";100 const string ExpectedActionLinks = "edit delete";101 var tableElements = new InternetPage(this.DriverContext)102 .OpenHomePage()103 .GoToTablesPage();104 var table = tableElements.GetTableElements();105 test.Info("Verifying surname displayed in the table, expected: " + ExpectedSurname);106 Assert.AreEqual(ExpectedSurname, table[0][0]);107 test.Info("Verifying action links displayed in the table, expected: " + ExpectedActionLinks);108 Assert.AreEqual(ExpectedActionLinks, table[3][5]);109 }110 [Test]111 public void DragAndDropTest()112 {113 var dragAndDrop = new InternetPage(this.DriverContext)114 .OpenHomePage()115 .GoToDragAndDropPage()116 .MoveElementAtoElementB();117 test.Info("Verifying element A was moved to element B");118 Assert.IsTrue(dragAndDrop.IsElementAMovedToB(), "Element is not moved.");119 }120 [Test]121 public void ReportDemoFailingTest()122 {123 const string ExpectedLeftFrameText = "LEFT";124 const string ExpectedMiddleFrameText = "CENTER";125 var nestedFramesPage = new InternetPage(this.DriverContext)126 .OpenHomePage()127 .GoToNestedFramesPage()128 .SwitchToFrame("frame-top");129 nestedFramesPage.SwitchToFrame("frame-left");130 test.Info("Verifying text displayed in left frame, expected: " + ExpectedLeftFrameText);131 Assert.AreEqual(ExpectedLeftFrameText, nestedFramesPage.LeftBody);132 nestedFramesPage.SwitchToParentFrame().SwitchToFrame("frame-middle");133 test.Info("Verifying text displayed in middle frame, expected: " + ExpectedMiddleFrameText);134 Assert.AreEqual(ExpectedMiddleFrameText, nestedFramesPage.MiddleBody);135 }136 }137}...

Full Screen

Full Screen

ProjectTestBase.cs

Source:ProjectTestBase.cs Github

copy

Full Screen

...34 /// The base class for all tests <see href="https://github.com/ObjectivityLtd/Ocaramba/wiki/ProjectTestBase-class">More details on wiki</see>35 /// </summary>36 public class ProjectTestBase : TestBase37 {38 private readonly DriverContext driverContext = new DriverContext();39 [ThreadStatic]40 private ExtentTest testContainer;41 [ThreadStatic]42 public static ExtentTest test;43 /// <summary>44 /// Gets or sets logger instance for driver45 /// </summary>46 public TestLogger LogTest47 {48 get49 {50 return this.DriverContext.LogTest;51 }52 set53 {54 this.DriverContext.LogTest = value;55 }56 }57 /// <summary>58 /// Gets or Sets the driver context59 /// </summary>60 protected DriverContext DriverContext61 {62 get63 {64 return this.driverContext;65 }66 }67 /// <summary>68 /// Before the class.69 /// </summary>70 [OneTimeSetUp]71 public void BeforeClass()72 {73 this.testContainer = TestExecutionManager.extent.CreateTest(TestContext.CurrentContext.Test.ClassName);74 this.DriverContext.CurrentDirectory = Directory.GetCurrentDirectory();75 this.DriverContext.Start();76 }77 /// <summary>78 /// After the class.79 /// </summary>80 [OneTimeTearDown]81 public void AfterClass()82 {83 PrintPerformanceResultsHelper.PrintAverageDurationMillisecondsInAppVeyor(this.DriverContext.PerformanceMeasures);84 PrintPerformanceResultsHelper.PrintPercentiles90DurationMillisecondsInAppVeyor(this.DriverContext.PerformanceMeasures);85 PrintPerformanceResultsHelper.PrintAverageDurationMillisecondsInTeamcity(this.DriverContext.PerformanceMeasures);86 PrintPerformanceResultsHelper.PrintPercentiles90DurationMillisecondsinTeamcity(this.DriverContext.PerformanceMeasures);87 this.DriverContext.Stop();88 }89 /// <summary>90 /// Before the test.91 /// </summary>92 [SetUp]93 public void BeforeTest()94 {95 test = this.testContainer.CreateNode(TestContext.CurrentContext.Test.Name);96 this.DriverContext.TestTitle = TestContext.CurrentContext.Test.Name;97 this.LogTest.LogTestStarting(this.driverContext);98 }99 /// <summary>100 /// After the test.101 /// </summary>102 [TearDown]103 public void AfterTest()104 {105 var status = TestContext.CurrentContext.Result.Outcome.Status;106 var errorMessage = TestContext.CurrentContext.Result.Message;107 this.DriverContext.IsTestFailed = TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed || !this.driverContext.VerifyMessages.Count.Equals(0);108 var filePaths = this.SaveTestDetailsIfTestFailed(this.driverContext);109 this.SaveAttachmentsToTestContext(filePaths);110 this.LogTest.LogTestEnding(this.driverContext);111 var javaScriptErrors = this.DriverContext.LogJavaScriptErrors();112 if (this.IsVerifyFailedAndClearMessages(this.driverContext) && TestContext.CurrentContext.Result.Outcome.Status != TestStatus.Failed)113 {114 Assert.Fail();115 }116 if (javaScriptErrors)117 {118 Assert.Fail("JavaScript errors found. See the logs for details");119 }120 if (status == TestStatus.Failed)121 {122 ExtentTestLogger.Fail(status, errorMessage);123 EmbedAttachmentsToExtentReport(filePaths);124 }125 else...

Full Screen

Full Screen

SelectWebElementTests.cs

Source:SelectWebElementTests.cs Github

copy

Full Screen

...13 [Test]14 public void SelectByIndexTest()15 {16 const string ExpectedOption = "Option 1";17 var dropdownPage = new InternetPage(this.DriverContext)18 .OpenHomePage()19 .GoToDropdownPage();20 dropdownPage.SelectByIndex(1);21 Assert.AreEqual(dropdownPage.SelectedOption(), ExpectedOption);22 test.Info("Verifying selected option, expected: " + ExpectedOption);23 }24 [Test]25 public void NoSuchElementExceptionByTextTest()26 {27 const string ElementText = "Qwerty.";28 var dropdownPage = new InternetPage(this.DriverContext)29 .OpenHomePage()30 .GoToDropdownPage();31 Assert.That(() => dropdownPage.SelectByText(ElementText, 10), Throws.Nothing);32 test.Info("Verifying it's possible to select element on dropdown by text: " + ElementText);33 }34 [Test]35 public void NoSuchElementExceptionByIndexTest()36 {37 const int ElementIndex = 7;38 var dropdownPage = new InternetPage(this.DriverContext)39 .OpenHomePage()40 .GoToDropdownPage();41 Assert.That(() => dropdownPage.SelectByIndex(ElementIndex), Throws.Nothing);42 test.Info("Verifying it's possible to select element on dropdown by element index: " + ElementIndex.ToString());43 }44 [Test]45 public void NoSuchElementExceptionByValueTest()46 {47 const string ElementValue = "qwerty";48 var dropdownPage = new InternetPage(this.DriverContext)49 .OpenHomePage()50 .GoToDropdownPage();51 Assert.That(() => dropdownPage.SelectByValue(ElementValue), Throws.Nothing);52 test.Info("Verifying it's possible to select element on dropdown by value: " + ElementValue);53 }54 }55}...

Full Screen

Full Screen

DriverContext

Using AI Code Generation

copy

Full Screen

1using Ocaramba.Tests.NUnitExtentReports;2using NUnit.Framework;3{4 {5 public void TestMethod()6 {7 }8 }9}10using Ocaramba.Tests.NUnitExtentReports;11using NUnit.Framework;12{13 {14 public void SetupTest()15 {16 }17 public void TeardownTest()18 {19 DriverContext.Driver.Quit();20 }21 }22}23using Ocaramba;24using NUnit.Framework;25{26 {27 public void OneTimeSetUp()28 {29 var driverFactory = new DriverFactory();30 DriverContext.Driver = driverFactory.Create(BrowserType.Chrome);31 }32 public void OneTimeTearDown()33 {34 DriverContext.Driver.Quit();35 }36 }37}38using NUnit.Framework;39using Ocaramba;40using Ocaramba.Tests.NUnitExtentReports;41using Ocaramba.Tests.PageObjects.TheInternet;42{43 {44 public void TestMethod()45 {46 var dragAndDropPage = new DragAndDropPage(DriverContext);47 dragAndDropPage.OpenHomePage();48 dragAndDropPage.DragAndDropElement();49 }50 }51}52using NUnit.Framework;53using Ocaramba;54using Ocaramba.Tests.NUnitExtentReports;55using Ocaramba.Tests.PageObjects.TheInternet;56{57 {

Full Screen

Full Screen

DriverContext

Using AI Code Generation

copy

Full Screen

1using Ocaramba;2using Ocaramba.Tests.NUnitExtentReports;3using NUnit.Framework;4{5 {6 public void TestMethod1()7 {8 }9 }10}11using Ocaramba;12using Ocaramba.Tests.NUnitExtentReports;13using NUnit.Framework;14{15 {16 public void TestMethod1()17 {18 }19 }20}21using Ocaramba;22using Ocaramba.Tests.NUnitExtentReports;23using NUnit.Framework;24{25 {26 public void TestMethod1()27 {

Full Screen

Full Screen

DriverContext

Using AI Code Generation

copy

Full Screen

1public void SetupTest()2{3 this.TestInitialize();4}5public void TeardownTest()6{7 this.TestCleanup();8}9public void TestMethod1()10{11}12public void SetupTest()13{14 this.TestInitialize();15}16public void TeardownTest()17{18 this.TestCleanup();19}20public void TestMethod1()21{22}23public void SetupTest()24{25 this.TestInitialize();26}27public void TeardownTest()28{29 this.TestCleanup();30}31public void TestMethod1()32{33}34public void SetupTest()35{36 this.TestInitialize();37}38public void TeardownTest()39{40 this.TestCleanup();41}42public void TestMethod1()43{44}45public void SetupTest()46{47 this.TestInitialize();48}49public void TeardownTest()50{51 this.TestCleanup();52}53public void TestMethod1()54{55}56public void SetupTest()57{58 this.TestInitialize();59}60public void TeardownTest()61{

Full Screen

Full Screen

DriverContext

Using AI Code Generation

copy

Full Screen

1using Ocaramba;2using Ocaramba.Tests.NUnitExtentReports;3using NUnit.Framework;4using OpenQA.Selenium;5using System;6{7 {8 public void StartBrowser()9 {10 Start(BrowserType.Chrome);11 }12 public void CloseBrowser()13 {14 Driver.Quit();15 }16 }17}18using Ocaramba;19using Ocaramba.Tests.NUnitExtentReports;20using NUnit.Framework;21using OpenQA.Selenium;22using System;23{24 {25 public void StartBrowser()26 {27 Start(BrowserType.Chrome);28 }29 public void CloseBrowser()30 {31 Driver.Quit();32 }33 }34}35using Ocaramba;36using Ocaramba.Tests.NUnitExtentReports;37using NUnit.Framework;38using OpenQA.Selenium;39using System;40{41 {42 public void StartBrowser()43 {44 Start(BrowserType.Chrome);45 }46 public void CloseBrowser()47 {48 Driver.Quit();49 }50 }51}

Full Screen

Full Screen

DriverContext

Using AI Code Generation

copy

Full Screen

1using Ocaramba;2using Ocaramba.Tests.NUnitExtentReports;3using NUnit.Framework;4{5 {6 public ProjectTestBase(DriverContext driverContext)7 : base(driverContext)8 {9 }10 }11}12using Ocaramba;13using Ocaramba.Tests.NUnitExtentReports;14using NUnit.Framework;15using System;16{17 {18 public ProjectTestBase(DriverContext driverContext)19 : base(driverContext)20 {21 }22 }23}24using Ocaramba;25using Ocaramba.Tests.NUnitExtentReports;26using NUnit.Framework;27using System;28{29 {30 public ProjectTestBase(DriverContext driverContext)31 : base(driverContext)32 {33 }34 }35}36using Ocaramba;37using Ocaramba.Tests.NUnitExtentReports;38using NUnit.Framework;39using System;40{41 {42 public ProjectTestBase(DriverContext driverContext)43 : base(driverContext)44 {45 }46 }47}48using Ocaramba;49using Ocaramba.Tests.NUnitExtentReports;50using NUnit.Framework;51using System;52{

Full Screen

Full Screen

DriverContext

Using AI Code Generation

copy

Full Screen

1{2 public void TestMethod1()3 {4 var driverContext = DriverContext;5 }6}7{8 public void TestMethod1()9 {10 var driverContext = DriverContext;11 }12}13{14 public void TestMethod1()15 {16 var driverContext = DriverContext;17 }18}19{20 public void TestMethod1()21 {22 var driverContext = DriverContext;23 }24}25{26 public void TestMethod1()27 {28 var driverContext = DriverContext;29 }30}31{32 public void TestMethod1()33 {34 var driverContext = DriverContext;35 }36}

Full Screen

Full Screen

DriverContext

Using AI Code Generation

copy

Full Screen

1using Ocaramba;2using Ocaramba.Tests.NUnitExtentReports;3using NUnit.Framework;4{5 {6 public void SampleTest1()7 {8 DriverContext.CurrentTest.Log(Status.Info, "Navigated to Google");9 DriverContext.CurrentTest.Log(Status.Info, "Page title is: " + DriverContext.CurrentDriver.Title);10 }11 }12}13using Ocaramba;14using Ocaramba.Tests.NUnitExtentReports;15using NUnit.Framework;16{17 {18 public void SampleTest1()19 {20 TestContext.WriteLine("Navigated to Google");21 TestContext.WriteLine("Page title is: " + DriverContext.CurrentDriver.Title);22 }23 }24}25using Ocaramba;26using Ocaramba.Tests.NUnitExtentReports;27using NUnit.Framework;28{29 {30 public void SampleTest1()31 {32 TestContext.WriteLine("Navigated to Google");33 TestContext.WriteLine("Page title is: " + DriverContext.CurrentDriver.Title);34 }35 }36}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Ocaramba automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful