java - Selenium looping sendKeys -
so have gotten far enough locate textbox on facebook, , send person message. want see if can create loop send multiple messages @ once. current problem have loop:
for (int = 0; < 20; i++) { messagebox.sendkeys("my friend's name " + + " "); messagebox.sendkeys(keys.enter); }
however, can once. print "my friend's name0" , stop. java says: element not attached page document.
i assuming because sent message, part of inspect element has changed? there way solve this?
get friend's name excel sheet
make method data excel file:-
public static void fn_fetchexceldata(string filepath,string columnname) throws ioexception{ string wbookpath=filepath; workbook wbookobj=fn_getworkbook(filepath); sheet sheetobj=wbookobj.getsheetat(0); row fstrowobj=sheetobj.getrow(0); int cellcount=fstrowobj.getlastcellnum(); int columnnumber=0; arraylist<string> al=new arraylist<string>(); for(int j=0; j<cellcount;j++){ if(fstrowobj.getcell(j, row.create_null_as_blank).getstringcellvalue().trim().equalsignorecase(columnname)){ columnnumber=j; break; } } int rowcnt=sheetobj.getlastrownum(); for(int i=1;i<=rowcnt;i++){ cell fstcellobj=sheetobj.getrow(i).getcell(columnnumber, row.create_null_as_blank); string columnval=fstcellobj.getstringcellvalue(); al.add(columnval); call excel method & use fn_fetchexceldata("your excel data path"); int j; int size = al.size(); for(j=0;j<size;j++) { system.out.println(al.get(j)); messagebox.sendkeys(al.get(j));
Comments
Post a Comment