【问题标题】:How to click this element with value 50 , i'm using casper for this this to select如何单击这个值为 50 的元素,我使用 casper 来选择这个
【发布时间】:2018-03-07 12:37:25
【问题描述】:

Location of the dropdown menu

三个下拉选项

这是它在select value 50: 的网页中的工作方式

【问题讨论】:

标签: javascript php html casperjs


【解决方案1】:

您可以使用casper.click()XPath expression 按文本内容点击元素。

您可以在您的案例中使用的 XPath 表达式是:

//div[@id="dnn_ctr1000_MainView_rgMain_ct100_ct103_ct101_PageSizeComboBox_DropDown"]/div[@class="rcbScroll rcbWidth"]/ul[@class="rcbList"]/li[text()="50"]

使用 CasperJS,您可以编写完整的程序:

var casper = require('casper').create();
var x = require('casper').selectXPath;

casper.start('https://example.com/');

casper.then(function () {
  this.click(x('//div[@id="dnn_ctr1000_MainView_rgMain_ct100_ct103_ct101_PageSizeComboBox_DropDown"]/div[@class="rcbScroll rcbWidth"]/ul[@class="rcbList"]/li[text()="50"]'));
});

casper.run();

这将允许您在包含文本内容50 的元素上模拟点击事件。

【讨论】:

    猜你喜欢
    • 2018-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-30
    • 1970-01-01
    • 2022-01-07
    • 2018-09-15
    • 2021-11-08
    相关资源
    最近更新 更多