2

I am trying with chromeless to click on a submit button whose code is:

<input value="Submit" onclick="normal_upload()" id="submitbutton" type="button">

I have tried

const screenshot = await chromeless
        .click('input#submitbutton')

and

const screenshot = await chromeless
        .click('#submitbutton')

and

const screenshot = await chromeless
        .click('input[value="Submit"]')

but none of these seem to work (nothing happens, and no error message).

What could be blocking the click?

Sulli
  • 763
  • 1
  • 11
  • 33

2 Answers2

1

With some luck, setting the scrollBeforeClick option to true in the Chromeless constructor options may solve the problem. If that does not help, or if it breaks something else, it might be worth trying to use the .scrollToElement() method to scroll to an element located some distance below the element that needs to be clicked. (It seems that scrolling is sometimes a few lines short of the necessary amount.)

Otto G
  • 670
  • 7
  • 14
  • scrollBeforeClick broke something else, but .scrollToElement worked (to an element *above* my button, scrolling to the button itself or an element below didn't work). But I thought chromeless was supposed to work headless too? Why would I have to care about scrolling? – Sulli May 14 '18 at 17:17
0

I've found that sometimes you need to .scrollToElement('input#submitbutton') for clicks to work.

Mike
  • 1,625
  • 3
  • 16
  • 19
  • not working for me. The scroll works though, so it's really not a problem of finding the selector, just clicking on it :( – Sulli Mar 08 '18 at 12:30
  • If nothing helps, google for “webdriver” in combination with “Node.js” for systems based on the currently more reliable https://www.w3.org/TR/webdriver/ API. – Otto G Apr 19 '18 at 14:11