vendredi 16 septembre 2016

UI react capybara button click test

I'm trying to get a simple menu bar icon to click. However, the id and class is not available. I've tried with page.execute_script().

HTML code

<button tabindex="0" type="button" style="border: 10px; box-sizing: border-box; display: inline-block; font-family: Roboto, sans-serif; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer; text-decoration: none; margin: 0px; padding: 0px; outline: none; font-size: 14px; font-weight: 500; transform: translate(0px, 0px); color: white; width: 16.6667%; text-transform: uppercase; background-color: rgb(63, 174, 73);">
  <div>
    <div style="display: flex; flex-direction: column; align-items: center; justify-content: center; height: 48px;">
      <!-- react-text: 57 -->Type<!-- /react-text -->
    </div>
  </div>
</button>

Capybara code

script = "document.getElementsByClassName('button')[0].click();"
page.execute_script(script)

Aucun commentaire:

Enregistrer un commentaire