【问题标题】:WebDriver press button Google playWebDriver 按下按钮 Google play
【发布时间】:2014-05-21 16:35:04
【问题描述】:

任务是在https://play.google.com/store/apps/category/FINANCE/collection/topselling_paid中按下“更多”按钮

这是截图 http://c2n.me/i9LC1O

我的代码是:

String url = "https://play.google.com/store/apps/category/FINANCE/collection/topselling_paid";
WebDriver driver = new HtmlUnitDriver();
driver.manage().timeouts().implicitlyWait(100000, TimeUnit.SECONDS);
        driver.get(url);
//Collects ONLY first 60 link. `enter code here`But I need more....
        ArrayList<WebElement> linksToApp = (ArrayList<WebElement>) driver
                .findElements((By.className("title")));
        ArrayList<String> urlToApp = new ArrayList<String>();

请帮帮我。

【问题讨论】:

  • 对我来说那个按钮是隐藏的。因此,单击它不会有任何效果。当我向下滚动页面时,“显示更多”是自动完成的,因此我不知道你想要实现什么,因为这不是页面看起来要做的。
  • 您没有看到“更多”按钮。我说的对吗?
  • 是的。根据我的调查,它从未显示过,当您使用 AJAX 请求向下滚动时,页面会自动获得“更多”结果。
  • 请在其他浏览器的帮助下尝试查看“更多”按钮。

标签: java button selenium webdriver


【解决方案1】:

你需要做类似的事情

driver.findElement(By.id("id-of-show_more-button")).click();

您可以通过右键单击元素找到元素 id,单击检查元素,然后检查 HTML 中的 id 属性

【讨论】:

  • 我试过了 driver.findElement(By.xpath("//*[@id='show-more-button']")).click();但是什么也没发生。请告诉我,这是个问题。
  • 尝试使用 id ,因为它总是更稳定:在您的情况下,它将是 driver.findElement(By.id("show-more-button")).click();您正在使用 HTML 单元驱动程序,因此屏幕上不会有任何显示。您应该只关心日志。另外,在旁注中,我看到 HTMLUnitDriver 本身并不是很稳定。
  • 我试着按照你说的去做。但它不起作用。仅收集前 60 个链接。但我需要更多......
  • 紧急!请帮帮我!我的Skype是flexin777。
猜你喜欢
  • 2016-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多