gpt4 book ai didi

node.js - 如何使用 chromeless API 从下拉列表中选择一个选项?

转载 作者:太空宇宙 更新时间:2023-11-03 22:08:58 25 4
gpt4 key购买 nike

我正在使用 chromeless API ( https://github.com/graphcool/chromeless )如何从下拉列表中选择一个选项?具体来说,我想选择具有 value="other"的最后一个选项。

我的 HTML 是:

enter image description here

最佳答案

您可以通过evaluate()来实现这一点方法允许您在加载的任何页面的浏览器上下文中评估任何 Javascript:

await chromeless
.goto('http://yourwebsite.com/yourpage')
.evaluate(() => {
select = document.querySelector('select.decline-form-select')
select.value = 'other'
})

或者,专门选择选择列表中的最后一项:

await chromeless
.goto('http://yourwebsite.com/yourpage')
.evaluate(() => {
document.querySelector('select.decline-form-select option:last-child').selected = true
})

关于node.js - 如何使用 chromeless API 从下拉列表中选择一个选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48120359/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com