Validating the sorting functionality using Selenium (Java) -
this first post help. please correct me if see wrong post.
i trying validate sorting functionality in web page selenium script (using java). here details...
first go user search results page multiple pages. has users details: user name, number of miles. there sort filter drop down values: values a-z, values z-a, miles most, miles least, newest members, oldest members . default sorting newest members. want validate: values a-z, values z-a, miles , miles least since see values in search page.
for looking solve same problem. below code worked me in validating sorting of string values in page
//declare variables int elecount; list<string> customernamea = new arraylist(); list<string> customernameb = new arraylist(); // check our customer elements , count them.... replace xxx xpath asserttrue(iselementpresent(by.xpath("xxx"))); elements = driver.findelements(by.xpath("xxx']")); elecount = elements.size(); system.out.println("element count: " + elecount); for(int = 2; < elecount; i++){ //capture customer name values //replace xxx xpath & replace value increments each element in xpath + + customernamea.add(driver.findelement(by.xpath("xxx")).gettext()); system.out.println(driver.findelement(by.xpath("xxx")).gettext()); customernameb.add(driver.findelement(by.xpath("xxx")).gettext()); } collections.sort(customernamea); (int i=0;i<customernamea.size();i++) { system.out.println("customer name input: " + customernameb.get(i) + "--customer name sorted input: " + customernamea.get(i)); if (!(customernamea.get(i).equals(customernameb.get(i)))) { system.out.println("customer names not sorted: " + i); break; } } }
Comments
Post a Comment