Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/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/7/css/42.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:如何在CSS中选择文本?_Python_Css_Selenium_Selenium Webdriver - Fatal编程技术网

Python Selenium:如何在CSS中选择文本?

Python Selenium:如何在CSS中选择文本?,python,css,selenium,selenium-webdriver,Python,Css,Selenium,Selenium Webdriver,有人可以建议我如何在提供的代码中使用Selenium Webdriver和Python查找并单击“客户端”: <g class="highcharts-legend" transform="translate(647,234)"> <g class="highcharts-legend-item" transform="translate(8,3)"> <text x="21" style="color:#333333;font-size:1

有人可以建议我如何在提供的代码中使用Selenium Webdriver和Python查找并单击“客户端”:

<g class="highcharts-legend" transform="translate(647,234)">
    <g class="highcharts-legend-item" transform="translate(8,3)">
        <text x="21" style="color:#333333;font-size:12px;font-weight:bold;cursor:pointer;fill:#333333;" text-anchor="start" y="15">Client</text>
        <rect x="0" y="4" width="16" height="12" fill="#4685BB">

   </g>
</g>

客户

您可以尝试此
CSS
选择器:

driver.find_element_by_css_selector("g.highcharts-legend-item>text").click()
XPath

driver.find_element_by_xpath("//*[name()='text' and text()='Client']").click()

您可以尝试此
CSS
选择器:

driver.find_element_by_css_selector("g.highcharts-legend-item>text").click()
XPath

driver.find_element_by_xpath("//*[name()='text' and text()='Client']").click()