我很确定这是一个简单的问题,但我找不到答案。
我有一个脚本,这是使用PageObjects编写的。这一切都由一个主"Run Test“类控制,并运行到几个Page对象类。
现在,我遇到的问题是,我需要在脚本的步骤3中选择一个系统生成的变量,然后在步骤5中使用它,但是这个变量没有被传递给那个类。
我做错了什么?
主类
class RunTest
{
static IWebDriver driver;
string PlanID; <- Tried setting here?
//Opens Chrome, Navigates to CTSuite, Logs in and Selects desired environment.
[TestFixtureSetUp]
public void Login()
{
... Login Code
}
[Test]
public void Test5()
{
//Set back to home page
driver.FindElement(By.XPath("//*[@id='ajaxLoader']")).Click();
var NetChange = new SwapNetwork(driver);
NetChange.ChangeTheNetwork("LEBC");
var SearchForClient = new GoTo(driver);
SearchForClient.GoToClient("810797");
var NewContract = new NewContracts(driver);
NewContract.AddNewContract("Test5", PlanID); //PlanID is set in this class
var NewFee = new NewFee(driver);
NewFee.AddNewFee("Test5");
var StartChecks = new NewFee(driver);
StartChecks.ExpectationChecks("Test5", PlanID); //Then needs to be used here
}变量通过以下方式设置
//Collect plan reference number
string PlanReference = driver.FindElement(By.XPath("//*[@id='ctl00_MainBody_Tabpanel1_lblRecord']")).Text;
Console.WriteLine("Plan Details: " + PlanReference);
var StringLength = PlanReference.Length;
PlanID = PlanReference.Substring(StringLength - 7, 7);在public void AddNewContract(string testName, string PlanID)中使用
StartCheck类中的第一行是计划ID的Console.Writeline,但它始终不返回任何内容
https://stackoverflow.com/questions/44519414
复制相似问题