문제

I need to process few lines of code over and over in RFT (java) so custom method/function/procedure is the best (and only) solution to this.

I have no java experience so I need some help with that.

The method will receive some parameters and will return no value.

Basically it will be entering new records into a database (web based application). How many records? It depends on data so I need to make it argument based.

the current code looks like

    text__firstname(ANY,NO_FLAGS).setText(dpString("StudentName"));
    text__surname(ANY,NO_FLAGS).setText(dpString("StudentSurnameName"));

in php the desired function would look like

   function add_student($first_name,$surname){
    text__firstname(ANY,NO_FLAGS).setText($first_name);
    text__surname(ANY,NO_FLAGS).setText($surname);
   }

so I can call it

   add_student(dpString("StudentName"),dpString("StudentSurnameName"));
도움이 되었습니까?

해결책 3

so I was looking for something like that

private boolean add_student($first_name,$surname){

  text__firstname(ANY,NO_FLAGS).setText($first_name);
  text__surname(ANY,NO_FLAGS).setText($surname);
  return true;
}

다른 팁

I'm a .net person more than a Java person but it should go something like the below, I've also never used RFT so I'm assuming that the inner text works. You will have to replace the ReplaceWithType with whatever type text__firstname and text_surname are.

public void AddStudent(ReplaceWithType text__firstname, ReplaceWithType text__surname)
{
    text__firstname(ANY,NO_FLAGS).setText(dpString("StudentName")); 
    text__surname(ANY,NO_FLAGS).setText(dpString("StudentSurnameName"));
}

I would recommend that you take a look at the Java API and get a good Java book.

You can write a method like this..

public void setTextValues(TestObject firstName , TestObject surName){

while(dp.dpnext()){
firstName(ANY,NO_FLAGS).setText(dpString("StudentName")); 
    surName(ANY,NO_FLAGS).setText(dpString("StudentSurnameName"));


}

}

dpnext command automatically iterates to the next record in data pool.

Hope this helps you!!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top