Best Ocaramba code snippet using Ocaramba.Tests.NUnitExtentReports.PageObjects.InternetPage.OpenHomePage
HerokuappTestsNUnit.cs
Source:HerokuappTestsNUnit.cs
...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}...
InternetPage.cs
Source:InternetPage.cs
...47 /// <summary>48 /// Methods for this HomePage49 /// </summary>50 /// <returns>Returns HomePage</returns>51 public InternetPage OpenHomePage()52 {53 var url = BaseConfiguration.GetUrlValue;54 this.Driver.NavigateTo(new Uri(url));55 Logger.Info(CultureInfo.CurrentCulture, "Opening page {0}", url);56 return this;57 }58 public InternetPage OpenHomePageWithUserCredentials()59 {60 var url = BaseConfiguration.GetUrlValueWithUserCredentials;61 this.Driver.NavigateTo(new Uri(url));62 Logger.Info(CultureInfo.CurrentCulture, "Opening page {0}", url);63 ExtentTestLogger.Debug("InternetPage: Opening page: " + url);64 return this;65 }66 public DropdownPage GoToDropdownPage()67 {68 ExtentTestLogger.Debug("InternetPage: Opening Dropdown page");69 this.Driver.GetElement(this.linkLocator.Format("dropdown")).Click();70 return new DropdownPage(this.DriverContext);71 }72 public MultipleWindowsPage GoToMultipleWindowsPage()...
SelectWebElementTests.cs
Source:SelectWebElementTests.cs
...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}...
OpenHomePage
Using AI Code Generation
1using NUnit.Framework;2using Ocaramba;3using Ocaramba.Tests.NUnitExtentReports.PageObjects;4{5 [Parallelizable(ParallelScope.Fixtures)]6 {7 private readonly InternetPage internetPage;8 public InternetPageTests(DriverContext driverContext)9 : base(driverContext)10 {11 this.internetPage = new InternetPage(this.DriverContext);12 }13 public void OpenHomePage()14 {15 this.internetPage.OpenHomePage();16 this.internetPage.WaitForPageLoad();17 }18 }19}20using System;21using System.Collections.Generic;22using System.Linq;23using System.Text;24using System.Threading.Tasks;25using Ocaramba;26using Ocaramba.Extensions;27using Ocaramba.Types;28{29 {30 link = new ElementLocator(Locator.CssSelector, "a[href='/']");31 public InternetPage(DriverContext driverContext)32 : base(driverContext)33 {34 }35 public void OpenHomePage()36 {37 }38 public void WaitForPageLoad()39 {40 this.Driver.WaitForElementToBeClickable(this.link, BaseConfiguration.LongTimeout);41 }42 }43}44using System;45using System.Collections.Generic;46using System.Linq;47using System.Text;48using System.Threading.Tasks;49using Ocaramba;50using Ocaramba.Extensions;51using Ocaramba.Types;52{53 {54 public ProjectPageBase(DriverContext driverContext)55 : base(driverContext)56 {57 }58 }59}60using System;61using System.Collections.Generic;62using System.Linq;63using System.Text;64using System.Threading.Tasks;65using Ocaramba;66using Ocaramba.Extensions;67using Ocaramba.Types;68{69 {70 public ProjectTestBase(DriverContext driverContext)71 : base(driverContext)72 {73 }74 }75}76using System;
OpenHomePage
Using AI Code Generation
1using Ocaramba;2using Ocaramba.Tests.NUnitExtentReports.PageObjects;3using NUnit.Framework;4{5 {6 public void OpenHomePage()7 {8 var internetPage = new InternetPage(this.DriverContext);9 internetPage.OpenHomePage();10 Assert.IsTrue(internetPage.IsLoaded(), "Page is not loaded");11 }12 }13}14using Ocaramba;15using Ocaramba.Tests.NUnitExtentReports.PageObjects;16using NUnit.Framework;17{18 {19 public void OpenHomePage()20 {21 var internetPage = new InternetPage(this.DriverContext);22 internetPage.OpenHomePage();23 Assert.IsTrue(internetPage.IsLoaded(), "Page is not loaded");24 }25 }26}27using Ocaramba;28using Ocaramba.Tests.NUnitExtentReports.PageObjects;29using NUnit.Framework;30{31 {32 public void OpenHomePage()33 {34 var internetPage = new InternetPage(this.DriverContext);35 internetPage.OpenHomePage();36 Assert.IsTrue(internetPage.IsLoaded(), "Page is not loaded");37 }38 }39}40using Ocaramba;41using Ocaramba.Tests.NUnitExtentReports.PageObjects;42using NUnit.Framework;43{44 {45 public void OpenHomePage()46 {
OpenHomePage
Using AI Code Generation
1using Ocaramba.Tests.NUnitExtentReports.PageObjects;2using NUnit.Framework;3using Ocaramba;4using Ocaramba.Types;5{6 [Parallelizable(ParallelScope.Fixtures)]7 {8 private readonly InternetPage internetPage;9 public InternetPageTests(DriverContext driverContext)10 : base(driverContext)11 {12 this.internetPage = new InternetPage(this.DriverContext);13 }14 public void OpenHomePage()15 {16 this.internetPage.OpenHomePage();17 Assert.AreEqual("The Internet", this.Driver.Title);18 Assert.AreEqual("Welcome to the-internet", this.internetPage.GetPageHeader());19 }20 }21}22using Ocaramba.Tests.NUnitExtentReports.PageObjects;23using NUnit.Framework;24using Ocaramba;25using Ocaramba.Types;26{27 [Parallelizable(ParallelScope.Fixtures)]28 {29 private readonly InternetPage internetPage;30 public InternetPageTests(DriverContext driverContext)31 : base(driverContext)32 {33 this.internetPage = new InternetPage(this.DriverContext);34 }35 public void OpenHomePage()36 {37 this.internetPage.OpenHomePage();38 Assert.AreEqual("The Internet", this.Driver.Title);39 Assert.AreEqual("Welcome to the-internet", this.internetPage.GetPageHeader());40 }41 }42}43using Ocaramba.Tests.NUnitExtentReports.PageObjects;44using NUnit.Framework;45using Ocaramba;46using Ocaramba.Types;47{48 [Parallelizable(ParallelScope.Fixtures)]49 {50 private readonly InternetPage internetPage;51 public InternetPageTests(DriverContext driverContext)52 : base(driverContext)53 {54 this.internetPage = new InternetPage(this.DriverContext);55 }56 public void OpenHomePage()57 {
OpenHomePage
Using AI Code Generation
1using Ocaramba.Tests.NUnitExtentReports.PageObjects;2using NUnit.Framework;3using Ocaramba;4using Ocaramba.Extensions;5using System;6using System.Collections.Generic;7using System.Linq;8using System.Text;9using System.Threading.Tasks;10using System.Threading;11{12 [Parallelizable(ParallelScope.Fixtures)]13 {14 private readonly InternetPage internetPage;15 public InternetPageTest(DriverContext driverContext)16 : base(driverContext)17 {18 this.internetPage = new InternetPage(this.DriverContext);19 }20 public void OpenHomePage()21 {22 this.internetPage.OpenHomePage();23 }24 }25}
OpenHomePage
Using AI Code Generation
1{2 using System;3 using NUnit.Framework;4 using Ocaramba;5 using Ocaramba.Tests.NUnitExtentReports.PageObjects;6 [Parallelizable(ParallelScope.Fixtures)]7 {8 public void OpenHomePageTest()9 {10 var internetPage = new InternetPage(this.DriverContext);11 internetPage.OpenHomePage();12 }13 }14}15using ExtentReportsNunit;16using ExtentReportsNunit;17using NUnit.Framework;18using Ocaramba;19using Ocaramba.Tests.NUnitExtentReports.PageObjects;20[Parallelizable(ParallelScope.Fixtures)]21{22 public void OpenHomePageTest()23 {24 var internetPage = new InternetPage(this.DriverContext);25 internetPage.OpenHomePage();26 }27}
OpenHomePage
Using AI Code Generation
1using Ocaramba;2using Ocaramba.Tests.NUnitExtentReports.PageObjects;3using NUnit.Framework;4{5 [Parallelizable(ParallelScope.Fixtures)]6 {7 public void OpenHomePage()8 {9 var internetPage = new InternetPage(this.DriverContext);10 internetPage.OpenHomePage();11 internetPage.CheckTitle();12 }13 }14}
OpenHomePage
Using AI Code Generation
1using Ocaramba;2using Ocaramba.Tests.NUnitExtentReports.PageObjects;3using NUnit.Framework;4{5 {6 public void OpenHomePageTest()7 {8 var internetPage = new InternetPage(this.DriverContext);9 internetPage.OpenHomePage();10 Assert.AreEqual("The Internet", internetPage.GetPageTitle());11 }12 }13}14using Ocaramba;15using Ocaramba.Extensions;16using Ocaramba.Types;17using Ocaramba.Tests.NUnitExtentReports.PageObjects;18using NUnit.Framework;19{20 {21 private readonly DriverContext _driverContext;22 _homePageLink = new ElementLocator(Locator.CssSelector, "a[href='/']");23 _formAuthenticationLink = new ElementLocator(Locator.CssSelector, "a[href='/login']");24 _dragAndDropLink = new ElementLocator(Locator.CssSelector, "a[href='/drag_and_drop']");25 _dropdownLink = new ElementLocator(Locator.CssSelector, "a[href='/dropdown']");
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!