【发布时间】:2018-01-12 05:41:10
【问题描述】:
您好,我正在运行 selenium webdriver c#,我正在尝试将某些创建的项目写入文件或控制台。
示例: 可以说我正在创造一辆汽车。我为汽车生成了一个车牌,说“08test1234”现在我想将该值写入某个位置,以便以后可以手动检查它。因为有时候我喜欢进去手动找车做一些修改。
我尝试了Console.WriteLine("08test1234"); 和Debug.Print("08test1234");,但无法让它们中的任何一个显示在任何位置。
非常感谢任何帮助。
这是其中一项测试
[Fact]
[Trait("2.", "Participants Tests")]
public void _2_Cancel_Create_Participant()
{
Utilities.CorrectLogin(_driver, Utilities.ManageWorkshopsURL);
_driver.Navigate().GoToUrl(Utilities.CreateParticipantURL);
Utilities.WaitforElement(_driver, "uiCreateParticipantFormCancelButton", 10);
_driver.FindElement(By.Id("uiIsAdminUserChk")).SendKeys(Keys.Space);
_driver.FindElement(By.Id("uiCreateParticipantFormCancelButton")).Click();
//Deal with Modal
Utilities.WaitforElement(_driver, "modal-body", 10);
Assert.Contains("Are you sure you wish to cancel? Any data you have entered will be lost.", _driver.PageSource);
_driver.FindElement(By.Id("uiConfirmationModalConfirmButton")).Click();
Assert.Equal(Utilities.ManageWorkshopsURL, _driver.Url);
Debug.Write("need to write this text to output");
}
public void Dispose()
{
_driver.Quit();
}
}
}
【问题讨论】:
-
您是否发现
Console.WriteLine("08test1234");有任何错误?必须在Console.WriteLine("08test1234");之前发生错误,并且您的程序永远不会到达该行。你能分享你的代码试验吗? -
您好,它通过了测试,只是没有向输出写入任何内容。我把它放在测试中
-
清理并重建您的项目并尝试
Console.WriteLine("08test1234");并更新我的状态。 -
嗨 试过了,还是没有任何显示。尝试将其写入 txt 文件会更容易吗?
-
是的,这可能更容易。