Skip to content

Commit

Permalink
Merge pull request #14 from amikolajczyk/master
Browse files Browse the repository at this point in the history
Add SetAtribute test
  • Loading branch information
tfajks authored Jun 22, 2016
2 parents 2022a20 + 08fc411 commit c9fbd30
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ public void HoversTest()
Assert.AreEqual(expected[0], text1After);
Assert.AreEqual(expected[1], text2After);
Assert.AreEqual(expected[2], text3After);
}

[Test]
public void SetAttributeTest()
{
var internetPage = new InternetPage(this.DriverContext)
.OpenHomePage();

internetPage.ChangeBasicAuthLink("/broken_images");
internetPage.BasicAuthLinkClick();

var brokenImagesPage = new BrokenImagesPage(this.DriverContext);

Assert.True(brokenImagesPage.IsPageHeaderElementEqualsToExpected("Broken Images"), "Page header element is not equal to expected 'Broken Images'");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CustomGrid.cs" />
<Compile Include="PageObjects\TheInternet\BrokenImagesPage.cs" />
<Compile Include="PageObjects\TheInternet\HttpCode200Page.cs" />
<Compile Include="PageObjects\TheInternet\ShiftingContentPage.cs" />
<Compile Include="PageObjects\TheInternet\SecureFileDownloadPage.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// <copyright file="BrokenImagesPage.cs" company="Objectivity Bespoke Software Specialists">
// Copyright (c) Objectivity Bespoke Software Specialists. All rights reserved.
// </copyright>
// <license>
// The MIT License (MIT)
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// </license>

namespace Objectivity.Test.Automation.Tests.PageObjects.PageObjects.TheInternet
{
using Common.Extensions;
using Common.Types;
using Objectivity.Test.Automation.Common;

public class BrokenImagesPage : InternetPage
{
private readonly ElementLocator
pageHeaderElement = new ElementLocator(Locator.CssSelector, "h3");

public BrokenImagesPage(DriverContext driverContext)
: base(driverContext)
{
}

public bool IsPageHeaderElementEqualsToExpected(string text)
{
return this.Driver.GetElement(this.pageHeaderElement).IsElementTextEqualsToExpected(text);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public class InternetPage : ProjectPageBase
/// Locators for elements
/// </summary>
private readonly ElementLocator
linkLocator = new ElementLocator(Locator.CssSelector, "a[href='/{0}']");
linkLocator = new ElementLocator(Locator.CssSelector, "a[href='/{0}']"),
basicAuthLink = new ElementLocator(Locator.XPath, "//a[contains(text(),'Auth')]");

public InternetPage(DriverContext driverContext)
: base(driverContext)
Expand Down Expand Up @@ -167,5 +168,17 @@ public FloatingMenuPage GoToFloatingMenu()
this.Driver.GetElement(this.linkLocator.Format("floating_menu")).Click();
return new FloatingMenuPage(this.DriverContext);
}

public void ChangeBasicAuthLink(string newAttributeValue)
{
var element = this.Driver.GetElement(this.basicAuthLink);
element.SetAttribute("href", newAttributeValue);
}

public void BasicAuthLinkClick()
{
var element = this.Driver.GetElement(this.basicAuthLink);
element.Click();
}
}
}

0 comments on commit c9fbd30

Please sign in to comment.