0
こんにちは私は、自動化されたテストをブラウザスタックに統合しようとしています。残念ながら、POMフレームワークを使用するのに役立つオンラインのものはありません。ページオブジェクトモデルフレームワークでBrowserstackを使用
私はseen thisですが、これは便利ですが基本テンプレートであり、ドライバを渡すためにページオブジェクトモデルを使用していません。 「オブジェクト参照がオブジェクトのインスタンスに設定されていません」というエラーが発生し続ける
using Macmillan.Specflow.Support.Models;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using System;
using System.Configuration;
using System.Diagnostics;
using TechTalk.SpecFlow;
namespace Macmillan.Specflow.Support.Steps
{
[Binding]
public class BaseSteps
{
public IWebDriver Driver { get; private set; }
[BeforeScenario]
public void BeforeScenario()
{
if (Process.GetProcessesByName("BrowserStackLocal").Length == 0)
new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "BrowserStackLocal.exe",
Arguments = ConfigurationManager.AppSettings["browserstack.key"] + " -forcelocal"
}
}.Start();
var capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.Version, "33");
capabilities.SetCapability("os", "windows");
capabilities.SetCapability("os_version", "8");
capabilities.SetCapability("browserName", "firefox");
capabilities.SetCapability("browserstack.user", ConfigurationManager.AppSettings["browserstack.user"]);
capabilities.SetCapability("browserstack.key", ConfigurationManager.AppSettings["browserstack.key"]);
capabilities.SetCapability("project", "LCI");
capabilities.SetCapability("name", ScenarioContext.Current.ScenarioInfo.Title);
capabilities.SetCapability("browserstack.local", true);
Driver = new RemoteWebDriver(new Uri(ConfigurationManager.AppSettings["browserstack.hub"]), capabilities);
Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
ScenarioContext.Current["driver"] = Driver;
}
[AfterScenario]
public void AfterScenario()
{
Driver.Quit();
}
}
using Macmillan.Specflow.Support.Models;
using OpenQA.Selenium;
using TechTalk.SpecFlow;
namespace Macmillan.Specflow.Steps.Steps
{
public class BaseSteps : Support.Steps.BaseSteps
{
#region Properties
public HomePage HomePage { get; private set; }
public EnglandPage EnglandPage { get; set; }
#endregion
#region Methods
[Given(@"I browse to Home page")]
public void GivenIBrowseToHomePage()
{
HomePage = new HomePage(Driver).BrowseTo();
}
[Given(@"I navigate to England Page")]
public void GivenINavigateToEnglandPage()
{
EnglandPage = HomePage.HomePageMenuBar.NavigateToEnglandPage();
}
#endregion
}
}
using Macmillan.Specflow.Support.Models.Partials;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.PageObjects;
using System.Configuration;
using TechTalk.SpecFlow;
namespace Macmillan.Specflow.Support.Models
{
public class HomePage
{
#region Constructors
public HomePage(IWebDriver driver)
{
Driver = driver;
Driver = (IWebDriver)ScenarioContext.Current["driver"];
PageFactory.InitElements(Driver, this);
HeaderNavigation = new HeaderNavigation(Driver);
HomePageMenuBar = new HomePageMenuBar(Driver);
}
#endregion
#region fields
[FindsBy(How = How.ClassName, Using = "text-headline")]
private IWebElement _header;
#endregion
#region properties
public HomePageMenuBar HomePageMenuBar { get; }
public HeaderNavigation HeaderNavigation { get; }
public IWebDriver Driver { get; set; }
#endregion
#region Methods
/// <summary>
/// Use the browser to browse to the Home Page.
/// </summary>
/// <returns>An instance of the Home page.</returns>
public HomePage BrowseTo()
{
Driver.Navigate().GoToUrl(ConfigurationManager.AppSettings["baseUrl"]);
return this;
}
#endregion Methods
}
}
using Macmillan.Specflow.Support.Models;
using NUnit.Framework;
using System;
using System.Text.RegularExpressions;
using TechTalk.SpecFlow;
namespace Macmillan.Specflow.Steps.Steps
{
[Binding]
public class LCIEnglandSteps : BaseSteps
{
#region properties
public AboutPage AboutPage { get; set; }
public ContactUsPage ContactUsPage { get; set; }
public FAQSPage FAQSPage { get; set; }
public IncidenceDetailsPage IncidenceDetailsPage { get; set; }
public MortalityDetailsPage MortalityDetailsPage { get; set; }
public PrevalenceDetailsPage PrevalenceDetailsPage { get; set; }
#endregion properties
#region methods
#region Givens
[Given(@"I navigate to the Macmillan Homepage")]
public void GivenINavigateToTheMacmillanHomepage()
{
HomePage.HeaderNavigation.NavigateToMacmillanPage();
}
[Given(@"I want to contact Macmillan")]
public void GivenIWantToContactMacmillan()
{
ContactUsPage = EnglandPage.EnglandPageMenuBar.NavigateToContactUs();
}
[Given(@"I want to filter the data by both CCG (.*) and Cancer (.*)")]
public void GivenIWantToFilterTheDataByBothCCGAndCancer(string p0, string p1)
{
EnglandPage.CcgFilter = p0;
EnglandPage.NavigateIteminCCGList(p0);
EnglandPage.CancerTypeFilter = p1;
EnglandPage.NavigateIteminCancerTypeList(p1);
EnglandPage.ApplyFilter();
}
[Given(@"I want to filter the data by Cancer (.*)")]
public void GivenIWantToFilterTheDataByCancer(string p0)
`enter code here` {`enter code here`
EnglandPage.CancerTypeFilter = p0;
EnglandPage.NavigateIteminCancerTypeList(p0);
EnglandPage.ApplyFilter();
}
どこでエラーが発生しましたか?例外の呼び出しスタックを追加できますか? –