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
Python 如何为selenium的HTML代码找到元素?_Python_Selenium_Xpath_Css Selectors_Robotframework - Fatal编程技术网

Python 如何为selenium的HTML代码找到元素?

Python 如何为selenium的HTML代码找到元素?,python,selenium,xpath,css-selectors,robotframework,Python,Selenium,Xpath,Css Selectors,Robotframework,如何从这个HTML代码中找到搜索框的定位器?我尝试了所有可能的方法,但没有成功。有很多选择: XPath = "//input[@placeholder='Enter a question']" CSS = "[type='search']" ID = "rc_select_1" 要定位图元,可以使用以下任一方法: 使用css\u选择器: input.ant-input.ant-input-lg[placeholder='Enter


如何从这个HTML代码中找到搜索框的定位器?我尝试了所有可能的方法,但没有成功。

有很多选择:

XPath = "//input[@placeholder='Enter a question']"
CSS = "[type='search']"
ID = "rc_select_1"

要定位图元,可以使用以下任一方法:

  • 使用
    css\u选择器

    input.ant-input.ant-input-lg[placeholder='Enter aquestion']
    
  • 使用
    xpath

    //input[@class='ant-input ant-input-lg' and @placeholder='Enter aquestion']
    

您可以在无法继续的地方共享一些代码吗?请不要将HTML作为图像发布,将其作为格式化文本发布,以便社区成员可以将其复制到xpath tester工具或其他工具中。