C# 如何使用c语言单击google结果页面中的第一个链接#
尝试通过c#进行硒测试,但是 driver.FindElement(By.LinkText(“练习表单-激情”))。单击()强> 未能单击第一个链接 注意:代码不完整C# 如何使用c语言单击google结果页面中的第一个链接#,c#,selenium,C#,Selenium,尝试通过c#进行硒测试,但是 driver.FindElement(By.LinkText(“练习表单-激情”))。单击() 未能单击第一个链接 注意:代码不完整 namespace PracticeFormTests { [TestClass] public class MyPracticeFormTests { private TestContext testContextInstance; private IWebDriver dri
namespace PracticeFormTests
{
[TestClass]
public class MyPracticeFormTests
{
private TestContext testContextInstance;
private IWebDriver driver;
private string appURL;
public MyPracticeFormTests()
{
}
[TestMethod]
[TestCategory("Chrome")]
public void ThePracticeFormTest()
{
driver.Navigate().GoToUrl("https://www.google.com/");
driver.FindElement(By.XPath("//input[@name='q']")).SendKeys("practiceselenium.com/practice-form.html");
driver.FindElement(By.XPath("//input[@name='q']")).Submit();
driver.FindElement(By.Id("//div[@class='g']/div[1]/div/div[1]/a")).Click();
driver.FindElement(By.LinkText("practice-form - passion")).Click();
driver.FindElement(By.Id("sex-1")).Click();
driver.FindElement(By.Id("exp-4")).Click();
driver.FindElement(By.Id("tea1")).Click();
driver.FindElement(By.Id("tea2")).Click();
driver.FindElement(By.XPath("//*[@id='continents']/option[4]")).Click();
driver.FindElement(By.XPath("//*[@id='continents']/option[7]")).Click();
driver.FindElement(By.XPath("//*[@id='selenium_commands']/option[3]")).Click();
driver.FindElement(By.XPath("//*[@id='selenium_commands']/option[5]")).Click();
driver.FindElement(By.Id("submit")).Click();
Assert.IsTrue(driver.Title.Contains("We're passionate about tea."), "Verified title of the page");
}
}
}
失败信息是什么?