[go: up one dir, main page]

0% found this document useful (0 votes)
23 views6 pages

Vegetarian

Uploaded by

Latha 1030
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
23 views6 pages

Vegetarian

Uploaded by

Latha 1030
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
Following selectors are allowed inthis solution old name + ypath(absolute and relative only, dynamic(axes) xpath is not allowed) + linkText Scenario: 1, Use appropriate Setup method to: Copy, Paste and use the following statement to set the driver property: System,setProperty("webdriver.gecko.driver’, "/home/user/Desktop/gecko © open application, © maximize the browser, © put an implicit wait of 10 second a Create atestng,xm by con}yting the TestNG class and put following 3 parameters tag: tl tag © ans 6 © Intest method: 3, Open the application url: http: 4, Click on “Order Now" 5, Switch driver to the new window opened by the driver and print the url 6, Assert(using Assert class) to check ifthe ttle of the page is "Bootstrap Example", 7, Select Type as Vegetarian, 8, Fetch all the options present in the main dish dropdown and print thelr text values on 9, Click on “Weekend Offers” ink 10. Fetch the number of links present in the page and print itn the console as: "The number {s;" followed by the number fetched 11, Click on "Contact Us' link 12. Switch the window to the newly opened tab. 13, Find the ContactDetalls.xls file provided in _ Desktop-> user repo -> Tn Participant -> AdditlonalSuppliedFiles -> Contac Copy below path to use excell in Selenium scrit ‘home/user/Desktop/user repo/To Participant/AdditionalSuppliedFiles/Co 14. Use Ito provide details into Contact Us fn | Seinport java.io.File; 6 import java.io. FiletnputStrean; | 7 import java.io.FileNotFoundéxception; 8 inport java.to.FiledutputStrean; 9 inport java.io, 10Exception; 10 inport java.util. List; LL inport java.util. set; 12 inport java.util. concurrent. TineUnit 2 14 Anport org. apache, conons, io, Fileutils; 15 import org. apache. poi hssf. usermodel, HSSECeLL; 16 Anport org. apache, poi hssf.usermodel, KSSFROWs 17 import org. apache, poi hssf,usermodel. SSFSheet: 1B port org. apache, poi hssf.usernodel.HSSeHork book; Anport org, openqa, seleniun. By; imort 0fg. openga,seleniun, utputType; it org. openga, selenium, TakesScreenshot rt org, openga,seleniun webDrivers | inport org. openga,seleniun webElenent; rt org.openga, selenium, support..ui. Select; Org, testng, annotations. AfterClass; 07g. testng, annotations, BeforeClass; rg. testng. annotations, Paraneters; Org. testng. annotations, Test; | WebDriver driver; Se BeforeClass ¥ re void setup() System. setProperty(*webdriver.gecko.driver', '/h top/ gecko driver. gat(*http: //Localhost:8 manage() ,window().maximze(); a ver manage(),timeouts() implica tLywait (10, TimeUndt. SECONDS) ; 43 44} | 458 @Paraneters({"type' "dish", "mobi le!}) 46 Gest 47 public void et typ, String dis, String cur, String mob) throws ese 48 driver. findElement(By, LinkText ("Order Now!) click() 149 SeteString> vindovhandl: gethindowHandles(); 0 ali handle:windovha B 9 ” 4 .SwitchTo() window(handl) ; an url= getCurrenturl(); iflurl.equals( : t wit. println(url); String titlesdriver.getTitle(); title, drive findElenent (By xpath('/ I Cedriver. findélenent (By.1d( v Select{); ae ens 67 ListedebElenent> ist=e, aetoptions|); 68 int size = list.size(); 69 for (int 10; Hesize;Ht+) 7 { 171 String option=list.get(H) .getText(); ) n \ System. out.println(option) B 4 driver, findelenent (By. LinkText ("Weekend Offers") .click(); int & .findElenents (By. taglane|" )).size(); 77 System. out.println('Th inks present 1§11"#a); | 78 driver. findélenent (ay, JinkTert tact Us')) .click()} 0 1 60 FiletnputStrean book=new FileinputStreant'/ } 81 HSsFHorkbook workbook = new 1ssPorkbock (both IBD HSGFSheet sheet=vorkbook. getSheet ("sheet"); 83 for (int 11; 1<¢3;i+) HSSFROW rowesheet .getRow(1); HSSFCell Cel L1=rov.getCelL(0); String nane=Cell1, ee vee driver, finden, xpath("// e\")")) sendkeys (nane) ; | HBSFOeIL Cel L2=rov.getcel (1); fing enail=celL2, getStringcelLValuel); iriver findelenent (By. xpath(*//*(@id=\" enail\"]")) ssendKeys (email); UL Cell3=row.getcell (2); ea a a indELenent (By. xpath("//*{ -celésrov.getell (3); serail getStringcelWalue()); a HSSFCalL Cel L4srov.getCelL(3); int beInteger,parselnt(Cell4.getStringcellValue(}); WebElenent driver. findelenent (By, xpath"//*l@id=\*help\"]*)}; Select f=new Select(d); 1104 f selectByIndex(b); N05 HESFCelL cellSrow.getCelL(4) bo: String addscell5.getStringcellvalue(); 107 108 driver, findElenent (By, xpath *]")) ssendkeys (add) ; 09 driver. findElenent (By. xpath(*/ vidi /di N13 Filevtils.copyfile(ten, new File( 12 File tenp=((TakesScreenshotdriver) .getScreenshotAs Output 14 HESFCeLL cel léerow.createcell (5); Py, H115 String are er. switchTo() alert() getText(); ie cell6,setCel lValue(nessaye) Ny ae tar cyt AledutputStrean out=new FiledutputStrean( hi workbook, write (out);

You might also like