C# 使用selenium c选择图像错误#

C# 使用selenium c选择图像错误#,c#,selenium-webdriver,C#,Selenium Webdriver,我正在进行下面的基本c#测试。我的测试基本上是进入www.asos.com,然后搜索特定项目。加载搜索结果时,我想单击返回的第一个项目。我试图使用CSS选择器来点击第一个想象,但我得到了一个例外。无效的选择器 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using OpenQA.Selenium; us

我正在进行下面的基本c#测试。我的测试基本上是进入www.asos.com,然后搜索特定项目。加载搜索结果时,我想单击返回的第一个项目。我试图使用CSS选择器来点击第一个想象,但我得到了一个例外。无效的选择器

    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;
using System.Threading;


namespace Exercise1
{
    class Exercise_2
    {
        static void Main(string[] args)
        {
            IWebDriver webDriver = new ChromeDriver();
            webDriver.Navigate().GoToUrl("http://www.asos.com/men/");
            webDriver.Manage().Window.Maximize();

            webDriver.FindElement(By.XPath(".//input[@data-testid='search-input']")).SendKeys("Polo Ralph Lauren Oxford Shirt In Regular Fit Blue");

            webDriver.FindElement(By.XPath(".//button[@data-testid='search-button-inline']")).Click();
            //*[@id="product-6153807"]/a/div[1]/img Xpath of the image to be clicked on
            webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
            webDriver.FindElement(By.CssSelector("6153807")).Click();

        }
    }

}

使用以下css选择器

article img
在代码中

webDriver.FindElement(By.CssSelector("article img")).Click();

通过检查,物品是img的父标签。请接受我的回答。当我检查时,我在任何地方都看不到我能看到的文章。不是直系父母。祖先/曾祖父母。(文章->a->部门->img)