0
[TestClass]
public class UnitTest1
{
[TestMethod()]
public void TestMethod1()
{
// Arrange
String expected = "text";
//a ACT
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/&hl=pl#identifier");
driver.Manage().Window.Maximize();
IWebElement email = driver.FindElement(By.XPath("//*[@id='Email']"));
email.Clear();
email.SendKeys("myemail");
IWebElement buttonElement = driver.FindElement(By.XPath("//*[@id='next']"));
buttonElement.Click();
var wait1 = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(10));
var password = wait1.Until(wd => wd.FindElement(By.XPath("//input[@id='Passwd']")));
password.Clear();
password.SendKeys("mypassword");
IWebElement login = driver.FindElement(By.XPath("//*[@id='signIn']"));
login.Click();
expected = driver.FindElement(By.ClassName("z0")).Text; //<-DOES'NT WORK
// Assert
Assert.IsTrue(expected.Contains("text"));
}
}
你好。我做了測試以登錄gmail。但我想在登錄後在此頁面上找到文本,並在測試結束時將其置於「斷言」狀態。 你能幫我嗎,怎麼做?如何從頁面獲取文本? Selenium,C#