Search code examples
opentest

timeout Exception even when element is already clicked


I am trying to click one button Sign In but even after button is clicked I am getting timeout exception.

I have verified the code and verified that I am using right locator.

description: CAP Demo Navigate to the GitHub website, find the React repo using the search functionality and go to the repo's homepage actors: - actor: WEB segments: - segment: 1 actions: - description: Navigate to the GitHub homepage action: org.getopentest.selenium.NavigateTo args: url: http://192.168.200.98:8780/CAFPortal/#/login

      - description: Enter Login id
        action: org.getopentest.selenium.SendKeys
        args:
          locator: {xpath: "//*[@id='login']/app-root/app-caf-login/div/div/div[2]/form/div[1]/input"} 
          text: ksood
          sendEnter: true

      - description: Enter password
        action: org.getopentest.selenium.SendKeys
        args:
          locator: {xpath: "//*[@id='login']/app-root/app-caf-login/div/div/div[2]/form/div[2]/input"}
          text: Acs@2018
          sendEnter: true

      - description: Pause for 60 second
        action: org.getopentest.selenium.ActionsPause
        args:
          durationMs: 60000

      - description: Display a greeting dialog box in the browser
        action: org.getopentest.selenium.ExecuteScript
        args:
        script: 
          var message = "Hello World!";
          alert(message);

      - description: Click on sign in 
        action: org.getopentest.selenium.Click
        args:
          locator: {xpath: "//*[@id='login']/app-root/app-caf-login/div/div/div[2]/form/div[3]/div/div/button"}

Just want the last testcase to pass


Solution

  • You don't need the sendEnter: true argument with any of the SendKeys actions. When you pass sendEnter: true , the action will "press" the enter key after sending the keys to the textbox element. So basically, in the test you showed, the first action will input the username and then press enter, thus trying to log in without a password, which will of course fail.

    The other problem is that you are using the ActionsPause keyword incorrectly (more info here). If you want to introduce a delay in your test, you can use the $delay() API, but you very rarely need to do this with OpenTest, since synchronization is built-in, meaning all test actions that perform some work on a UI element know how to wait for that element to be available before doing the work.