Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors after adding a new function to a button in index.html js #34

Open
Carrosen opened this issue Apr 12, 2019 · 1 comment
Open

Errors after adding a new function to a button in index.html js #34

Carrosen opened this issue Apr 12, 2019 · 1 comment

Comments

@Carrosen
Copy link

Problem

Getting error when running cucumber after implementing show/hide function for add contact button in html, added the same function for the save contact button aswell. Everything works on the localhost but the tests are failing. See screenshot

Background

All green before the new function

Spec

When('I click {string}', async function(string) {
  return await this.clickOnButton(string)
});
  async clickOnButton(btnName) {
    const btnSelector = this.btnSelectorFromName(btnName.toLowerCase())
    await this.page.waitForSelector(btnSelector)
    await this.page.click(btnSelector)

Implementation code

  <script type="text/javascript">
    function showHideDiv(ele) {
      var srcElement = document.getElementById(ele);
      if (srcElement != null) {
        if (srcElement.style.display == "block") {
          srcElement.style.display = 'none';
        }
        else {
          srcElement.style.display = 'block';
        }
        return false;
      }
    }
  </script>
        <input type="button" value="Add Contacts" onClick="showHideDiv('divMsg')"/><br><br>
        <div id="divMsg" style="background-color: #006969; color: #ffffff; height: 200px; width: 200px; text-align: center; display:none">
    <input class="save-contact" type="submit" value="Save Contact" onClick="showHideDiv('divMsg')"/><br><br>

Screenshots

image

How did you try to solve the problem?

Went through the code but can't find the error,
Tried to google it, it may be something to do with puppeteer but I don't think that is the case here. So I did not find anything relevant.

@oliverochman
Copy link

You need to add a class to your input field which calls on the function showHideDiv('divMsg'). The test cant find it because of that.

<input class="add-contact" type="button" value="Add Contacts" onClick="showHideDiv('divMsg')"/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants