Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用c语言单击google结果页面中的第一个链接#_C#_Selenium - Fatal编程技术网

C# 如何使用c语言单击google结果页面中的第一个链接#

C# 如何使用c语言单击google结果页面中的第一个链接#,c#,selenium,C#,Selenium,尝试通过c#进行硒测试,但是 driver.FindElement(By.LinkText(“练习表单-激情”))。单击() 未能单击第一个链接 注意:代码不完整 namespace PracticeFormTests { [TestClass] public class MyPracticeFormTests { private TestContext testContextInstance; private IWebDriver dri

尝试通过c#进行硒测试,但是 driver.FindElement(By.LinkText(“练习表单-激情”))。单击() 未能单击第一个链接

注意:代码不完整

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");
        }
    }
}

失败信息是什么?