我是一个新手,对于动态按钮使用selenium很困难。我正在编写selenium webdriver js脚本。
我在stackoverflow上搜索了一些类似的错误页面,但没有一个解决我的问题。
我想使用这个xpath。
/dom[@domain='localhost:3000']//div[#'search-results']//button[@innertext='Add Contact']
这是我的代码:
driver.wait(until.elementIsVisible(driver.findElement(By.xpath("/dom[@domain='localhost:3000']//div[#'search-results']//button[@innertext='Add Contact']"))))
并出现了以下错误
InvalidSelectorError: invalid selector: Unable to locate an element with the xpa
th expression /dom[@domain='localhost:3000']//div[#'search-results']//button[@in
nertext='Add Contact'] because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '/dom[@domai
n='localhost:3000']//div[#'search-results']//button[@innertext='Add Contact']' i
s not a valid XPath expression.
以下是HTML代码
<button class="btn btn-success btn-sm pull-right" data-email-id="user3@netas.com.tr" data-user-id="user3@test1.netas.com.tr" data-name="user3 test">Add Contact</button>
你能帮我识别我的问题吗?