【问题标题】:Data not retrieving when clicking on search button单击搜索按钮时未检索数据
【发布时间】:2017-03-21 07:08:38
【问题描述】:

搜索按钮在框架内,我正在使用以下代码连接到框架。

driver.switchTo().frame("autoCompleteDialogIF");

我可以去框架部分。

搜索按钮语法:

<a href="javascript:findButtonAction();">Find</a>

在框架部分,我有文本框,当我在文本框中输入值并执行搜索时,没有检索到与文本匹配的数据。

使用的代码:

WebElement elementclick = driver.findElement(By.xpath(".//*[@id='filterPanelFindButton']/a"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", elementclick);

【问题讨论】:

  • 您能否提供更多信息: 1. 您是如何确认它的框架的? 2. 您如何确认您正在连接到框架,向我们展示您的代码? 3. 可以分享一下相关的HTML DOM吗?

标签: selenium button search frames


【解决方案1】:

尝试使用java-script executor方法点击元素。

WebElement elementclick = driver.findElement(By.xpath("//a[contains(text(), 'Find')]"));
((JavascriptExecutor) driver).executeScript("arguments[0].click();", elementclick);

尝试使用xpath定位器和Explicit wait方法点击元素。

WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//a[contains(text(), 'Find')]"))));
driver.findElement(By.xpath("//a[contains(text(), 'Find')]")).click();

【讨论】:

  • 如果解决了您的问题,请将此答案标记为Accepted
【解决方案2】:

我认为你可以这样使用:

driver.findElement(By.linkText("Find"))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-03
    • 1970-01-01
    • 2020-02-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多