【发布时间】:2019-08-19 18:30:58
【问题描述】:
我正在尝试单击“搜索”按钮,但没有成功。我也尝试搜索 iframe,但没有 iframe。
这是我的“搜索”按钮 html 标签:
<input type="submit" value="search">
这是我用来点击搜索按钮的 xpath:
driver.findElement(By.xpath("//*[@id='mainDiv']/table/tbody/tr/td/div[3]/blockquote/fieldset/input[1]")).click();
我尝试过的以下方法:
new Actions(driver).moveToElement("//*[@id='mainDiv']/table/tbody/tr/td/div[3]/blockquote/fieldset/input[1]").perform();
JavascriptExecutor jse = (JavsscriptExecutor)driver; jse.executeScript("document.getElementById(//*[@id='mainDiv']/table/tbody/tr/td/div[3]/blockquote/fieldset/input[1]").focus().click();");
new WebDriverEait(driver, 10).until(ExpectedConditions.ElementToBeClickable(By.cssSelector(Inpout.submit[value='search']"))).click();
driver.findElement(By.cssSelector(".submit[value='search']")).click();
上面的方法应该可以点击“搜索”按钮。
但是,我遇到了异常:无法使用 cssSelector 或 xpath 或 id 找到元素
【问题讨论】: