如何选择路线编号。
<table cellspacing="0" class="route__table" id="route-selection-table">
<tr class="route" route-no="12345">
<input id="page-uuid" type="hidden" value="241e3808-fff-4564-a8e3-3232238f226a711"><td class="route__number">123459</td>
<td class="route__name">CORPORATION LIMITED CENTRE</td>
<td class="route__selected">
</td>
</tr>
我正在尝试这个xpath(这里路由是动态变化的(,所以我正在传递值
route='1234'
self.driver.find_element_by_xpath("//*[@id='route-selection-table']/tbody/[contains(text(),'" + route + "')]").click()
selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //*[@id='route-selection-table']/tbody/[contains(text(),'12345')] because of the following error:
E SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//*[@id='route-selection-table']/tbody/[contains(text(),'12345')]' is not a valid XPath expression.
E (Session info: chrome=91.0.4472.77)
....AppDataLocalProgramsPythonPython38libsite-packagesseleniumwebdriverremoteerrorhandler.py:242: InvalidSelectorException
尝试以下XPath-1.0表达式:
self.driver.find_element_by_xpath("//*[@id='route-selection-table']//*[contains(text(),'" + route + "')]").click()