![](/img/trans.png)
[英]Not able to click on Radio button where radio button change order on the web ui page Selenium Web Driver Java
[英]Not Able to click on “Search” button Selenium Web Driver Java
我试图单击“搜索”按钮,但没有运气。 我也尝试搜索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的元素
为什么使用绝对xpath而是尝试相对xpath如下所示
driver.findElement(By.xpath("//*[@type='submit'])).click();
基于“搜索”按钮的html标签,它看起来像网页上存在的“提交”按钮。 您可以像普通按钮一样在Web元素上使用click()方法,也可以在页面上的任何Web元素上或在提交按钮本身上使用Submit()方法。
尝试找到Search(Submit)元素
driver.findElement(By.xpath("//*[@type='submit'])).submit();
或者,您可以在该页面上的任何其他网络元素上调用Submit()方法。
driver.findElement(By.xpath("//*[@id='some_id'])).submit();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.