i have two methods in same class method1() and method2(). method 1() is to read a 'String' and extract integers from that string and method2 () is to perform a click operation. This click operation changes the 'string' which is the input of method1 () . Evreythign is working fine but my problem is Case 1 When i am calling these two methods from another class in following way -
method1();-------- 1
method2();-------- 2
method1();---------3
i get a clear result which shows the result of line 1 is different from line 3 becuase the string was changed by line 2 BUT
Case 2 when i am calling method1() inside method2 () in the same class in the following way -
method2();{
method1();---------1
click statement of method2;
method1();---------2
}
and calling this method2(); from another class it doesnt work line 1 and line 2 gives same result.
where i am wrong in case 2 or its not possible to call a public method of the same class twice in another public method ?? please guide.
if you need code details here it is :-
public void clickOnFaces(int n) {
ArrayList<Integer> ratingLikes = ratingLikes(n);
int likes = ratingLikes.get(0);
int total = ratingLikes.get(1);
seleniumclient.elements(Mappings.face).get(n).click();
ArrayList<Integer> updatedRatingLikes = ratingLikes(n);
int c = updatedRatingLikes.get(0);
int d = updatedRatingLikes.get(1);
}
public ArrayList ratingLikes(int n) {
seleniumactions.waitForElement(Mappings.ratingLikes);
ArrayList<Integer> likes = new ArrayList<>();
Pattern p = Pattern.compile("\\d+");
Matcher m = p.matcher(seleniumclient.elements(Mappings.ratingLikes).get(n).getText());
while (m.find()) {
likes.add(Integer.parseInt(m.group()));
}
return likes;
Issue is the value of 'c' and 'd' is same as 'likes' and 'total'. how ever they change when i keep only the click statement in clickonfaces() and call these mthods from different class example :
object.ratingLikes(int 0);
object.clickOnFaces(int 0);
object.ratingLikes(int 0);