eclipse - How to verify text everytime after posting with Selenium WebDriver using java? -


i have comment page people can write comment in text field , post comment clicking on submit button.like facebook comment.after posting comment, have verified comment.now want add 2nd comment , want verify 2nd comment.so there way verify text/comment every time after posting? in advance.

you can try following code:

protected boolean istextpresent(string text){         try{             boolean b = driver.getpagesource().contains(text);             return b;         }         catch(exception e){             return false;         }     }  string s[] = {"test comment1", "test comment2"};         for(int =0; i<s.length; i++){             driver.findelement(by.name("comment_body[und][0][value]")).sendkeys(s[i]);             driver.findelement(by.xpath("//a[@onclick='commnet_form_submit_handler(); return false;']")).click();             asserttrue(istextpresent(s[i]));         } 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -