...11 public static void registersuccess() {12 // TODO Auto-generated method stub13 //SpringApplication.run(MainController.class, args);14 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");15 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();16 driver.get("http://localhost:8080/register");17 driver.findElement(By.name("name")).click();18 driver.findElement(By.name("name")).sendKeys("alaaa");19 driver.findElement(By.name("UserID")).click();20 driver.findElement(By.name("UserID")).sendKeys("5");21 driver.findElement(By.name("pass")).click();22 driver.findElement(By.name("pass")).sendKeys("1234");23 driver.findElement(By.name("user_type")).click();24 driver.findElement(By.name("user_type")).sendKeys("storeowner");25 driver.findElement(By.xpath("/html/body/form/input[5]")).click();26 driver.findElement(By.xpath("/html/body/a/button")).click();27 String expected = "http://localhost:8080/login";28 String actual = driver.getCurrentUrl();29 Assert.assertEquals(expected, actual);30 31 32 33 }34 public static void registerfailuserType() {35 // TODO Auto-generated method stub36 //SpringApplication.run(MainController.class, args);37 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");38 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();39 driver.get("http://localhost:8080/register");40 driver.findElement(By.name("name")).click();//el mfrod yrun walahi41 driver.findElement(By.name("name")).sendKeys("alaaa");42 driver.findElement(By.name("UserID")).click();43 driver.findElement(By.name("UserID")).sendKeys("5");44 driver.findElement(By.name("pass")).click();45 driver.findElement(By.name("pass")).sendKeys("1234");46 driver.findElement(By.name("user_type")).click();47 driver.findElement(By.name("user_type")).sendKeys("STOREowner");48 driver.findElement(By.xpath("/html/body/form/input[5]")).click();49 driver.findElement(By.xpath("/html/body/a/button")).click();50 String expected = "http://localhost:8080/register";51 String actual = driver.getCurrentUrl();52 Assert.assertEquals(expected, actual);53 54 55 56 }57 public static void registerfailID() {58 // TODO Auto-generated method stub59 //SpringApplication.run(MainController.class, args);60 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");61 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();62 driver.get("http://localhost:8080/register");63 driver.findElement(By.name("name")).click();//el mfrod yrun walahi64 driver.findElement(By.name("name")).sendKeys("alaaa");65 driver.findElement(By.name("UserID")).click();66 driver.findElement(By.name("UserID")).sendKeys("alaa");67 driver.findElement(By.name("pass")).click();68 driver.findElement(By.name("pass")).sendKeys("1234");69 driver.findElement(By.name("user_type")).click();70 driver.findElement(By.name("user_type")).sendKeys("storeowner");71 driver.findElement(By.xpath("/html/body/form/input[5]")).click();72 driver.findElement(By.xpath("/html/body/a/button")).click();73 String expected = "http://localhost:8080/register";74 String actual = driver.getCurrentUrl();75 Assert.assertEquals(expected, actual);76 77 78 79 }80 public static void loginsuccess() {81 // TODO Auto-generated method stub82 //SpringApplication.run(MainController.class, args);83 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");84 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();85 driver.get("http://localhost:8080/login");86 driver.findElement(By.name("name")).click();87 driver.findElement(By.name("name")).sendKeys("salsabel");88 driver.findElement(By.name("pass")).click();89 driver.findElement(By.name("pass")).sendKeys("123");90 driver.findElement(By.name("user_type")).click();91 driver.findElement(By.name("user_type")).sendKeys("storeowner");92 driver.findElement(By.xpath("/html/body/form/input[4]")).click();93 driver.findElement(By.xpath("/html/body/form/input[4]")).click();94 String expected = "failed";95 String actual = driver.getTitle();96 Assert.assertEquals(expected, actual);97}98 public static void loginfailpass() {99 // TODO Auto-generated method stub100 //SpringApplication.run(MainController.class, args);101 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");102 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();103 driver.get("http://localhost:8080/login");104 driver.findElement(By.name("name")).click();//el mfrod yrun walahi105 driver.findElement(By.name("name")).sendKeys("salsabel");106 driver.findElement(By.name("pass")).click();107 driver.findElement(By.name("pass")).sendKeys("122");108 driver.findElement(By.name("user_type")).click();109 driver.findElement(By.name("user_type")).sendKeys("storeowner");110 driver.findElement(By.xpath("/html/body/form/input[4]")).click();111 driver.findElement(By.xpath("/html/body/form/input[4]")).click();112 String expected = "failed";113 String actual = driver.getTitle();114 Assert.assertEquals(expected, actual);115} 116 public static void loginfailsqlinjection() {117 // TODO Auto-generated method stub118 //SpringApplication.run(MainController.class, args);119 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");120 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();121 driver.get("http://localhost:8080/login");122 driver.findElement(By.name("name")).click();//el mfrod yrun walahi123 driver.findElement(By.name("name")).sendKeys("salsabel");124 driver.findElement(By.name("pass")).click();125 driver.findElement(By.name("pass")).sendKeys("'='");126 driver.findElement(By.name("user_type")).click();127 driver.findElement(By.name("user_type")).sendKeys("storeowner");128 driver.findElement(By.xpath("/html/body/form/input[4]")).click();129 driver.findElement(By.xpath("/html/body/form/input[4]")).click();130 String expected = "failed";131 String actual = driver.getTitle();132 Assert.assertEquals(expected, actual);133}134 public static void addbrandsucess() {135 // TODO Auto-generated method stub136 //SpringApplication.run(MainController.class, args);137 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");138 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();139 driver.get("http://localhost:8080/login");140 driver.findElement(By.name("name")).click();141 driver.findElement(By.name("name")).sendKeys("rawan");142 driver.findElement(By.name("pass")).click();143 driver.findElement(By.name("pass")).sendKeys("456");144 driver.findElement(By.name("user_type")).click();145 driver.findElement(By.name("user_type")).sendKeys("admin");146 driver.findElement(By.xpath("/html/body/a[1]/button")).click();//submit147 driver.findElement(By.xpath("/html/body/form/input[4]")).click();//gotoaddbrand148 driver.findElement(By.name("name")).click();149 driver.findElement(By.name("name")).sendKeys("brand");150 driver.findElement(By.name("brand_category")).click();151 driver.findElement(By.name("brand_category")).sendKeys("clothes");152 driver.findElement(By.name("user_type")).click();153 driver.findElement(By.name("user_type")).sendKeys("storeowner");154 driver.findElement(By.xpath("/html/body/div/form/input[3]")).click();155 driver.findElement(By.xpath("/html/body/div/form/input[3]")).click();156 String expected = "addbrand";157 String actual = driver.getTitle();158 Assert.assertEquals(expected, actual);159 160 161 }162 public static void addbrandfailname() {//name can be a number163 // TODO Auto-generated method stub164 //SpringApplication.run(MainController.class, args);165 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");166 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();167 driver.get("http://localhost:8080/login");168 driver.findElement(By.name("name")).click();169 driver.findElement(By.name("name")).sendKeys("rawan");170 driver.findElement(By.name("pass")).click();171 driver.findElement(By.name("pass")).sendKeys("456");172 driver.findElement(By.name("user_type")).click();173 driver.findElement(By.name("user_type")).sendKeys("admin");174 driver.findElement(By.xpath("/html/body/a[1]/button")).click();//submit175 driver.findElement(By.xpath("/html/body/form/input[4]")).click();//gotoaddbrand176 driver.findElement(By.name("name")).click();177 driver.findElement(By.name("name")).sendKeys("12");178 driver.findElement(By.name("brand_category")).click();179 driver.findElement(By.name("brand_category")).sendKeys("clothes");180 driver.findElement(By.name("user_type")).click();181 driver.findElement(By.name("user_type")).sendKeys("storeowner");182 driver.findElement(By.xpath("/html/body/div/form/input[3]")).click();183 driver.findElement(By.xpath("/html/body/div/form/input[3]")).click();184 String expected = "addbrand";185 String actual = driver.getTitle();186 Assert.assertEquals(expected, actual);187 }188 public static void addbrandfailbrand() {//brand can be number189 // TODO Auto-generated method stub190 //SpringApplication.run(MainController.class, args);191 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");192 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();193 driver.get("http://localhost:8080/login");194 driver.findElement(By.name("name")).click();195 driver.findElement(By.name("name")).sendKeys("rawan");196 driver.findElement(By.name("pass")).click();197 driver.findElement(By.name("pass")).sendKeys("456");198 driver.findElement(By.name("user_type")).click();199 driver.findElement(By.name("user_type")).sendKeys("admin");200 driver.findElement(By.xpath("/html/body/a[1]/button")).click();//submit201 driver.findElement(By.xpath("/html/body/form/input[4]")).click();//gotoaddbrand202 driver.findElement(By.name("name")).click();203 driver.findElement(By.name("name")).sendKeys("brand");204 driver.findElement(By.name("brand_category")).click();205 driver.findElement(By.name("brand_category")).sendKeys("clothes");206 driver.findElement(By.name("user_type")).click();207 driver.findElement(By.name("user_type")).sendKeys("storeowner");208 driver.findElement(By.xpath("/html/body/div/form/input[3]")).click();209 driver.findElement(By.xpath("/html/body/div/form/input[3]")).click();210 String expected = "addbrand";211 String actual = driver.getTitle();212 Assert.assertEquals(expected, actual);213 }214 public static void addproductsuccess() {215 // TODO Auto-generated method stub216 //SpringApplication.run(MainController.class, args);217 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");218 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();219 driver.get("http://localhost:8080/login");220 driver.findElement(By.name("name")).click();221 driver.findElement(By.name("name")).sendKeys("rawan");222 driver.findElement(By.name("pass")).click();223 driver.findElement(By.name("pass")).sendKeys("456");224 driver.findElement(By.name("user_type")).click();225 driver.findElement(By.name("user_type")).sendKeys("admin");226 driver.findElement(By.xpath("/html/body/a[1]/button")).click();//submit227 driver.findElement(By.xpath("/html/body/a[2]/button")).click();228 driver.findElement(By.name("name")).click();229 driver.findElement(By.name("name")).sendKeys("scarf");230 driver.findElement(By.name("ProductID")).click();231 driver.findElement(By.name("ProductID")).clear();232 driver.findElement(By.name("ProductID")).sendKeys("2");233 driver.findElement(By.name("Price")).clear();234 driver.findElement(By.name("Price")).click();235 driver.findElement(By.name("Price")).sendKeys("100");236 driver.findElement(By.name("Category")).click();237 driver.findElement(By.name("Category")).sendKeys("clothes");238 driver.findElement(By.name("quantity")).click();239 driver.findElement(By.name("quantity")).clear();240 driver.findElement(By.name("quantity")).sendKeys("300");241 driver.findElement(By.name("store_name")).click();242 driver.findElement(By.name("store_name")).sendKeys("zara");243 driver.findElement(By.xpath("/html/body/div/form/input[7]")).click();244 String expected = "addproduct";245 String actual = driver.getTitle();246 Assert.assertEquals(expected, actual);247 248 249 }250 public static void addproductfailcategory() {//category not exist251 // TODO Auto-generated method stub252 //SpringApplication.run(MainController.class, args);253 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");254 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();255 driver.get("http://localhost:8080/login");256 driver.findElement(By.name("name")).click();257 driver.findElement(By.name("name")).sendKeys("rawan");258 driver.findElement(By.name("pass")).click();259 driver.findElement(By.name("pass")).sendKeys("456");260 driver.findElement(By.name("user_type")).click();261 driver.findElement(By.name("user_type")).sendKeys("admin");262 driver.findElement(By.xpath("/html/body/a[1]/button")).click();//submit263 driver.findElement(By.xpath("/html/body/a[2]/button")).click();264 driver.findElement(By.name("name")).click();265 driver.findElement(By.name("name")).sendKeys("scarf");266 driver.findElement(By.name("ProductID")).click();267 driver.findElement(By.name("ProductID")).clear();268 driver.findElement(By.name("ProductID")).sendKeys("2");269 driver.findElement(By.name("Price")).clear();270 driver.findElement(By.name("Price")).click();271 driver.findElement(By.name("Price")).sendKeys("100");272 driver.findElement(By.name("Category")).click();273 driver.findElement(By.name("Category")).sendKeys("clothes");274 driver.findElement(By.name("quantity")).click();275 driver.findElement(By.name("quantity")).clear();276 driver.findElement(By.name("quantity")).sendKeys("300");277 driver.findElement(By.name("store_name")).click();278 driver.findElement(By.name("store_name")).sendKeys("zara");279 driver.findElement(By.xpath("/html/body/div/form/input[7]")).click();280 String expected = "addproduct";281 String actual = driver.getTitle();282 Assert.assertEquals(expected, actual);283 284 285 }286 public static void addproductstore() {//storename not exist287 // TODO Auto-generated method stub288 //SpringApplication.run(MainController.class, args);289 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");290 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();291 driver.get("http://localhost:8080/login");292 driver.findElement(By.name("name")).click();293 driver.findElement(By.name("name")).sendKeys("rawan");294 driver.findElement(By.name("pass")).click();295 driver.findElement(By.name("pass")).sendKeys("456");296 driver.findElement(By.name("user_type")).click();297 driver.findElement(By.name("user_type")).sendKeys("admin");298 driver.findElement(By.xpath("/html/body/a[1]/button")).click();//submit299 driver.findElement(By.xpath("/html/body/a[2]/button")).click();300 driver.findElement(By.name("name")).click();301 driver.findElement(By.name("name")).sendKeys("scarf");302 driver.findElement(By.name("ProductID")).click();303 driver.findElement(By.name("ProductID")).clear();304 driver.findElement(By.name("ProductID")).sendKeys("2");305 driver.findElement(By.name("Price")).clear();306 driver.findElement(By.name("Price")).click();307 driver.findElement(By.name("Price")).sendKeys("100");308 driver.findElement(By.name("Category")).click();309 driver.findElement(By.name("Category")).sendKeys("clothes");310 driver.findElement(By.name("quantity")).click();311 driver.findElement(By.name("quantity")).clear();312 driver.findElement(By.name("quantity")).sendKeys("300");313 driver.findElement(By.name("store_name")).click();314 driver.findElement(By.name("store_name")).sendKeys("zara");315 driver.findElement(By.xpath("/html/body/div/form/input[7]")).click();316 String expected = "addproduct";317 String actual = driver.getTitle();318 Assert.assertEquals(expected, actual);319 320 321 }322 public static void statisticsMaxProduct() {323 // TODO Auto-generated method stub324 //SpringApplication.run(MainController.class, args);325 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");326 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();327 driver.get("http://localhost:8080/newstatistic");328 driver.findElement(By.xpath("/html/body/div/form/input[7]")).click();329 driver.findElement(By.xpath("/html/body/a[1]/button")).click();330 String expected = "http://localhost:8080/maxproduct";331 String actual = driver.getCurrentUrl();332 Assert.assertEquals(expected, actual);333 334 335 }336 public static void statisticsMinProduct() {337 // TODO Auto-generated method stub338 //SpringApplication.run(MainController.class, args);339 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");340 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();341 driver.get("http://localhost:8080/newstatistic");342 driver.findElement(By.xpath("/html/body/div/form/input[7]")).click();343 driver.findElement(By.xpath("/html/body/a[2]/button")).click();344 String expected = "http://localhost:8080/minproduct";345 String actual = driver.getCurrentUrl();346 Assert.assertEquals(expected, actual);347 348 349 }350 public static void statisticssumUsers() {351 // TODO Auto-generated method stub352 //SpringApplication.run(MainController.class, args);353 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");354 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();355 driver.get("http://localhost:8080/newstatistic");356 driver.findElement(By.xpath("/html/body/div/form/input[7]")).click();357 driver.findElement(By.xpath("/html/body/a[3]/button")).click();358 String expected = "http://localhost:8080/sumofusers";359 String actual = driver.getCurrentUrl();360 Assert.assertEquals(expected, actual);361 362 363 }364 public static void statisticssumProduct() {365 // TODO Auto-generated method stub366 //SpringApplication.run(MainController.class, args);367 System.setProperty("webdriver.chrome.driver", "C:\\demo\\chromedriver.exe");368 org.openqa.selenium.chrome.ChromeDriver driver = new org.openqa.selenium.chrome.ChromeDriver();369 driver.get("http://localhost:8080/newstatistic");370 driver.findElement(By.xpath("/html/body/div/form/input[7]")).click();371 driver.findElement(By.xpath("/html/body/a[4]/button")).click();372 String expected = "http://localhost:8080/sumofproducts";373 String actual = driver.getCurrentUrl();374 Assert.assertEquals(expected, actual);375 376 377 }378 379 380}...