public static void main(String[] args) { // TODO Auto-generated method stub
//all columns n rows of webTable initiated int count_rows=5;int count_cols=7; int m=1;int col=0;String Day_s="29";String c=" " ; int R=0;int n=1;
//xpath in parts String p1="//*[@id='ui-datepicker-div']/div[2]/table/tbody/tr["; String p2="]/td["; String p3="]/*"; //getting the page of makemytrip website WebElement v; WebDriver w=new FirefoxDriver(); List <WebElement> z=new ArrayList <WebElement>(); w.get("http://www.makemytrip.com/flights"); w.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS); w.findElement(By.xpath("//*[@id='start_date_sec']/span[2]")).click();
//row n col representation for(m=1;m<=count_rows;m++)//Try m=5==========================>it works fine {
for(n=1;n<=count_cols;n++)//Try n=3=========================>it works fine { System.out.println("C"+count_cols); c=p1+m+p2+n+p3; System.out.println("here xpath"+c); v=w.findElement(By.xpath(c));//<==========Some issue here on debugging[Not sure what ====================== System.out.println("size"+v.getSize()); System.out.println("v.gettxet"+v.getText());
if(v.getText().matches(Day_s))
{ v.click(); break; }
else { System.out.println("not match"); }
} }
} }
Note: Issue is....for loop never crosses m=1,n=1. Day_s=29 ,so:xpath=//*[@id='ui-datepicker-div']/div[2]/table/tbody/tr[5]/td[3]/a If i specify m=5,n=3 ,it selects the correct day from calander,other wise NO. Can you please help me in running this 2 for loops appropriately...