我打算使用find元素在網頁中查找按鈕,該頁面可以包含以下按鈕ID之一。僅針對Chrome獲取org.openqa.selenium.InvalidSelectorException
driver.findElements(By.xpath("//*[contains(@id,'topBtn')]")) driver.findElements(By.xpath("//*[contains(@id,'WSMplasticTop')]")) driver.findElements(By.xpath("//*[contains(@id,'bottomApplyBtn')]"))
上述代碼工作時,我使用的Firefox驅動程序,其中,作爲得到下面的錯誤,當我在Chrome驅動按預期運行。
org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression //*[contains(@id='bottomApplyBtn')] because of the following error: SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//*[contains(@id='bottomApplyBtn')]' is not a valid XPath expression.
只是想知道我是否做了任何錯誤
謝謝安德森。它現在有效 – Hariharbalaji