2

クロムレス API を使用しています ( https://github.com/graphcool/chromeless ) ドロップダウン リストからオプションを選択するにはどうすればよいですか? 具体的には、value="other" を持つ最後のオプションを選択したいと考えています。

私のHTMLは:

ここに画像の説明を入力

4

2 に答える 2

1

これは、ロードしたページのブラウザ コンテキスト内で 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
  })
于 2018-01-08T04:47:46.490 に答える