クロムレス API を使用しています ( https://github.com/graphcool/chromeless ) ドロップダウン リストからオプションを選択するにはどうすればよいですか? 具体的には、value="other" を持つ最後のオプションを選択したいと考えています。
私のHTMLは:
クロムレス API を使用しています ( https://github.com/graphcool/chromeless ) ドロップダウン リストからオプションを選択するにはどうすればよいですか? 具体的には、value="other" を持つ最後のオプションを選択したいと考えています。
私のHTMLは:
これは、ロードしたページのブラウザ コンテキスト内で Javascript を評価できるevaluate()メソッドを使用して実現できます。
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
})