The UAT Automation Kit provides an API that lets you take advantage of Selenium WebDriver to interact with common elements in Infinity-based applications such as Blackbaud CRM. You can use Selenium's WebDriver and Wait pattern to drive browser interactions.
This tutorial guides you through the steps to create a custom interaction with the Selenium WebDriver and to use the WebDriver and Wait pattern to drive browser interactions. In this walkthrough, you will:
Then update the behavior-driven development test to confirm that you can navigate from the Constituents functional area to the Revenue functional area.
@DelvingDeeper
Scenario: Log into BBCRM, load a functional area, and change functional area.
Given I have logged into BBCRM and navigated to functional area "Constituents"
When I navigate to functional area "Revenue"
Then the panel header caption is "Revenue"
At the beginning of the step file, insert using Blackbaud.UAT.Core.Base
using Blackbaud.UAT.Core.Crm
, and using Blackbaud.UAT.Base
BaseSteps
p0
functionalArea
p0
headerCaption
using System;
using System.Collections.Generic;
using Blackbaud.UAT.Base;
using Blackbaud.UAT.Core.Base;
using Blackbaud.UAT.Core.Crm;
using TechTalk.SpecFlow;
namespace Delving_Deeper
{
[Binding]
public class SampleTestsSteps : BaseSteps
{
[Given(@"I have logged into BBCRM and navigated to functional area ""(.*)""")]
public void GivenIHaveLoggedIntoBbcrmAndNavigatedToFunctionalArea(string functionalArea)
{
ScenarioContext.Current.Pending();
}
[When(@"I navigate to functional area ""(.*)""")]
public void WhenINavigateToFunctionalArea(string functionalArea)
{
ScenarioContext.Current.Pending();
}
[Then(@"the panel header caption is ""(.*)""")]
public void ThenThePanelHeaderCaptionIs(string headerCaption)
{
ScenarioContext.Current.Pending();
}
}
}
ScenarioContext.Current.Pending();
Delete ScenarioContext.Current.Pending();
BBCRMHomePage.Login(); MyCustomBBCrmHomePage.NavigateToFunctionalArea(functionalArea);
[Given(@"I have logged into BBCRM and navigated to functional area ""(.*)""")]
public void GivenIHaveLoggedIntoBbcrmAndNavigatedToFunctionalArea(string functionalArea)
{
BBCRMHomePage.Login();
CustomBBCrmHomePage.NavigateToFunctionalArea(functionalArea);
}
If you build the project at this point with the unimplemented class and method in place, the build should fail.
BBCRMHomePage
At the beginning of the class file, insert using Blackbaud.UAT.Core.Crm
using OpenQA.Selenium
using OpenQA.Selenium.Support.UI
MyCustomBBCrmHomePage
BBCRMHomePage
NavigateToFunctionalArea
NotImplementedException
using System;
using Blackbaud.UAT.Core.Crm;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
namespace Delving_Deeper
{
public class CustomBBCrmHomePage : BBCRMHomePage
{
public static void NavigateToFunctionalArea(string caption)
{
throw new NotImplementedException();
}
}
}
If you attempt to build the project at this point with the exception specified for the method, the build should now succeed.
WebDriverTimeoutException
{
WebDriverWait navigateWaiter = new WebDriverWait(Driver, TimeSpan.FromSeconds(TimeoutSecs));
navigateWaiter.IgnoreExceptionTypes(typeof(InvalidOperationException));
navigateWaiter.Until(driver =>
{
throw new NotImplementedException();
});
}
NotImplementedException
driver
Displayed
Click
WebDriverWait navigateWaiter = new WebDriverWait(Driver, TimeSpan.FromSeconds(TimeoutSecs));
navigateWaiter.IgnoreExceptionTypes(typeof(InvalidOperationException));
navigateWaiter.Until(driver =>
{
IWebElement functionalAreaElement = driver.FindElement(null);
if (!functionalAreaElement.Displayed) return false;
functionalAreaElement.Click();
return true;
});
For now, update the code driver .FindElement
IWebElement functionalAreaElement = driver.FindElement(By.XPath(String.Format("//button[text()='{0}']", caption)));
ScenarioContext.Current.Pending();
[Given(@"I have logged into BBCRM and navigated to functional area ""(.*)""")]
public void GivenIHaveLoggedIntoBbcrmAndNavigatedToFunctionalArea(string functionalArea)
{
BBCRMHomePage.Login();
CustomBBCrmHomePage.NavigateToFunctionalArea(functionalArea);
}
[When(@"I navigate to functional area ""(.*)""")]
public void WhenINavigateToFunctionalArea(string functionalArea)
{
CustomBBCrmHomePage.NavigateToFunctionalArea(functionalArea);
}
[Then(@"the panel header caption is ""(.*)""")]
public void ThenThePanelHeaderCaptionIs(string headerCaption)
{
if (!BaseComponent.Exists(Panel.getXPanelHeaderByText(headerCaption)))
FailTest(String.Format("'{0}' was not in the header caption.", headerCaption));
}