vendredi 22 septembre 2017

can't pass value to the input fied in test case

I would like to pass a value to the input fied, in the test case. however this is not working. Below is my code.

   class Mypage extends Page {
    static content = { 

       inputfield { withFrame ("myFrame") {$('input',name:'myInputField') } 

    }
   }
 }

Then tested it this way:

given:
    String thevalue = "hello"
then:
    to Mypage
and:
    inputfield >> thevalue

With this code I get the

StaleElementReference error and the chrome driver information

I then tried the following by putting the thevalue variable in Mypage class:

class Mypage extends Page {

      public  String thevalue = "hello"

      static content = { 

           inputfield { withFrame ("myFrame") 
{$('input',name:'myInputField') } 


    }
   }
 }

Then tested it the same way with no given:

then:
    to Mypage
and:
    inputfield >> thevalue

I Still get the same error.

I then tried a third form:

class Mypage extends Page {

      //public  String thevalue = "hello"

      static content = { 

           inputfield { withFrame ("myFrame") 
{ thevalue -> $('input',name:'myInputField').value(thevalue ) } 


    }
   }
 }

Then tested it in 2 ways:

then:
    to Mypage
and:
    inputfield("hello")

and this way:

then:
    to Mypage
and:
    inputfield >> "hello"

The only way which is working is when I pass the value directly in the class

         inputfield { withFrame ("myFrame") 
{  $('input',name:'myInputField').value("hello") } 

But the goal is to the pass the value in the test. How do I do that

Aucun commentaire:

Enregistrer un commentaire