我对specflow是个新手。目前,我有一个问题,如何从浏览器的按钮点击获得响应文本。下面是我的代码
Scenario Outline:Download Questions and it should contain csv file extension
Given I am logged in as a user
When I select value "Ordinary" of select object with id "QuestionType"
And I select value "Answered" of select object with id "DisplayStatus"
And I click on the Download button在浏览器中,当我点击download按钮时,它会下载一个csv文件,而我想要编写相同的场景,我如何检查响应文本是否为csv?
如果你需要更多的信息,请告诉我。
好的,我正在使用selenium驱动程序来运行这些特性。
下面是一些代码
[Given(@"I am logged in as (?:a|an) (.* user)")]
public void GivenIAmLoggedInAs(LoginTypeName loginTypeName)
{
string pageUrl = PageFactory.GetPageUrlFor(PageName.Home);
CurrentDriver.GoToWithBase(pageUrl, _baseWebsite);
CurrentDriver.FindElementById(LoginFactory.GetLoginElementFor(loginTypeName)).Click();
WaitUntilClickableById("footer");
}发布于 2014-08-11 12:53:21
这里有一些参考:Selenium WebDriver File Download Testing
您应该使用浏览器将webdriver设置为自动下载,而无需询问位置。当您的测试已经将文件下载到您的测试环境中时,您可以使用System.IO来断言文件名。
https://stackoverflow.com/questions/25134083
复制相似问题