├── 90DaysProjectday2 ├── 90Days_ProjectDay ├── BDD ├── Feature_file │ └── Carwale.Feature ├── RunnerFile │ └── Carwale.runner └── Steps │ └── Carwale.steps ├── Day11_Snapdeal ├── Day12_Carwale ├── Day13_Shiksha ├── Day14_Zalando ├── Day6_Bigbasket ├── Day7_BikeStore ├── Day8_PepperFry ├── Day9_DemoCRM ├── Subtask_Automation ├── day1code ├── day2_testleaf_Nykaa ├── day3_MakeMyTrip └── day4_hpStore.in /90DaysProjectday2: -------------------------------------------------------------------------------- 1 | package twentyOneDayChallenge; 2 | 3 | import java.io.File; 4 | import java.util.NoSuchElementException; 5 | 6 | import org.openqa.selenium.By; 7 | import org.openqa.selenium.JavascriptExecutor; 8 | import org.openqa.selenium.WebElement; 9 | import org.openqa.selenium.chrome.ChromeDriver; 10 | import org.openqa.selenium.interactions.Actions; 11 | import org.openqa.selenium.support.ui.ExpectedConditions; 12 | import org.openqa.selenium.support.ui.Select; 13 | import org.openqa.selenium.support.ui.WebDriverWait; 14 | 15 | public class ProjectDay2Sel90 { 16 | 17 | public static void main(String[] args) throws InterruptedException { 18 | 19 | System.setProperty("webdriver.chrome.driver", "./postman/chromedriver.exe"); 20 | 21 | ChromeDriver driver = new ChromeDriver(); 22 | 23 | driver.get("https://azure.microsoft.com/en-in/pricing/calculator/"); 24 | 25 | JavascriptExecutor js = (JavascriptExecutor)driver; 26 | 27 | System.out.println("Navigated to the desired Website"); 28 | 29 | driver.manage().window().maximize(); 30 | 31 | Actions action = new Actions(driver); 32 | 33 | action.moveToElement(driver.findElement(By.id("navigation-pricing"))).click().build().perform(); 34 | Thread.sleep(3000); 35 | 36 | System.out.println("Cliked on Pricing button"); 37 | 38 | driver.findElement(By.linkText("Pricing calculator")).click(); 39 | Thread.sleep(3000); 40 | 41 | System.out.println("Cliked on Pricing calculator"); 42 | 43 | driver.findElementByXPath("//div[@class='category-container']//button[text()='Containers']").click(); 44 | 45 | System.out.println("Cliked on Containers"); 46 | 47 | driver.findElementByXPath("(//span[@class='product']//span[text()='Container Instances'])[2]").click(); 48 | Thread.sleep(2000); 49 | 50 | System.out.println("Cliked on Container Instances"); 51 | 52 | driver.findElement(By.id("new-module-loc")).click(); 53 | Thread.sleep(2000); 54 | 55 | WebElement dropDown = driver.findElementByXPath("(//select[@aria-label='Region'])[1]"); 56 | 57 | Select dropDownSelect = new Select(dropDown); 58 | 59 | dropDownSelect.selectByVisibleText("South India"); 60 | 61 | System.out.println("First dropdown selected"); 62 | 63 | driver.findElementByXPath("//div[@class='wa-textNumber']//input[@aria-label='Seconds']").clear(); 64 | Thread.sleep(2000); 65 | 66 | driver.findElementByXPath("//div[@class='wa-textNumber']//input[@aria-label='Seconds']").sendKeys("180000"); 67 | 68 | WebElement dropDown2 = driver.findElementByXPath("(//div[@class='calculator-dropdown ']//select[@aria-label='Memory'])[1]"); 69 | 70 | Select dropDownSelect2 = new Select(dropDown2); 71 | 72 | dropDownSelect2.selectByVisibleText("4 GB"); 73 | 74 | System.out.println("Second dropdown selected"); 75 | 76 | driver.findElement(By.id("devtest-toggler")).click(); 77 | Thread.sleep(2000); 78 | 79 | System.out.println("Toggled on for Containers"); 80 | 81 | WebElement dropDown3 = driver.findElementByXPath("(//div//select[@aria-label='Currency'])[1]"); 82 | 83 | Select dropDownSelect3 = new Select(dropDown3); 84 | 85 | dropDownSelect3.selectByVisibleText("Indian Rupee (₹)"); 86 | Thread.sleep(3000); 87 | 88 | System.out.println("Third dropdown selected"); 89 | 90 | String text = driver.findElementByXPath("(//span[text()='Monthly cost']/parent::div/span[@class='numeric']/span)[1]").getText(); 91 | 92 | System.out.println("Estimated monthly cost is :"+text); 93 | 94 | driver.findElementByXPath("(//button[contains(@class,'calculator-button button-transparent')])[4]").click(); 95 | Thread.sleep(4000); 96 | 97 | System.out.println("File's Exported"); 98 | 99 | File file = new File("C:\\Users\\vivekaka\\Downloads\\ExportedEstimate.xlsx"); 100 | 101 | if(file.exists()) { 102 | 103 | System.out.println("File path found"); 104 | } 105 | 106 | else { 107 | 108 | System.out.println("File path isn't found"); 109 | } 110 | 111 | WebDriverWait wait = new WebDriverWait(driver, 20); 112 | 113 | 114 | WebElement exmpScenario = driver.findElementByXPath("//li[@id='solution-architectures-picker']//a[text()='Example Scenarios']"); 115 | 116 | js.executeScript("arguments[0].scrollIntoView();", exmpScenario); 117 | js.executeScript("arguments[0].click();", exmpScenario); 118 | 119 | System.out.println("Clicked Example Scenarios"); 120 | 121 | driver.findElementByXPath("//span[text()='CI/CD for Containers']").click(); 122 | 123 | System.out.println("clicked CI/CD for containers"); 124 | 125 | wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[text()='Add to estimate']"))); 126 | 127 | WebElement ele = driver.findElementByXPath("//button[text()='Add to estimate']"); 128 | 129 | js.executeScript("arguments[0].click()", ele); 130 | 131 | wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//span[text()='Estimate added!']"))); 132 | System.out.println("Estimate Added!"); 133 | 134 | 135 | WebElement dD = driver.findElementByXPath("//select[@class='select currency-dropdown']"); 136 | 137 | Select dropDown4 = new Select(dD); 138 | 139 | dropDown4.selectByVisibleText("Indian Rupee (₹)"); 140 | 141 | System.out.println("Rupee Selected"); 142 | 143 | Thread.sleep(2000); 144 | 145 | action.moveToElement(driver.findElementByXPath("//button[@name='devTestSelected']")).click().build().perform(); 146 | 147 | System.out.println("SHOW DEV/TEST PRICING clicked"); 148 | 149 | driver.findElementByXPath("(//button[contains(@class,'calculator-button button-transparent')])[4]").click(); 150 | Thread.sleep(4000); 151 | 152 | File file2 = new File("C:\\\\Users\\\\vivekaka\\\\Downloads\\\\ExportedEstimate (1).xlsx"); 153 | 154 | if(file2.exists()) { 155 | 156 | System.out.println("File path 2 is found"); 157 | } 158 | 159 | else { 160 | 161 | System.out.println("File path 2 isn't found"); 162 | } 163 | 164 | } 165 | 166 | } 167 | -------------------------------------------------------------------------------- /90Days_ProjectDay: -------------------------------------------------------------------------------- 1 | package twentyOneDayChallenge; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Set; 6 | 7 | import org.openqa.selenium.By; 8 | import org.openqa.selenium.Keys; 9 | import org.openqa.selenium.WebDriver; 10 | import org.openqa.selenium.WebElement; 11 | import org.openqa.selenium.chrome.ChromeDriver; 12 | import org.openqa.selenium.chrome.ChromeOptions; 13 | import org.openqa.selenium.interactions.Actions; 14 | import org.openqa.selenium.support.ui.ExpectedConditions; 15 | import org.openqa.selenium.support.ui.Select; 16 | import org.openqa.selenium.support.ui.WebDriverWait; 17 | 18 | public class ProjectDaySel90 { 19 | 20 | public static void main(String[] args) throws InterruptedException { 21 | 22 | 23 | ChromeOptions options = new ChromeOptions(); 24 | 25 | options.addArguments("--disable-notifications"); 26 | 27 | System.setProperty("webdriver.chrome.driver", "./postman/chromedriver.exe"); 28 | 29 | ChromeDriver driver = new ChromeDriver(options); 30 | 31 | driver.get("https://www.ajio.com/shop/women"); 32 | 33 | driver.manage().window().maximize(); 34 | 35 | driver.findElement(By.tagName("input")).sendKeys("Bags"); 36 | Thread.sleep(2000); 37 | 38 | driver.findElement(By.xpath("(//span[text()='Women Handbags'])[1]")).click(); 39 | Thread.sleep(2000); 40 | 41 | Actions action = new Actions(driver); 42 | 43 | action.moveToElement(driver.findElement(By.className("five-grid"))).click().build().perform(); 44 | Thread.sleep(2000); 45 | 46 | WebElement sortBY = driver.findElementByXPath("//div[@class='filter-dropdown']//select[1]"); 47 | 48 | Select dropDown = new Select(sortBY); 49 | 50 | dropDown.selectByVisibleText("What's New"); 51 | Thread.sleep(2000); 52 | 53 | System.out.println("Filtered out"); 54 | 55 | action.moveToElement(driver.findElement(By.xpath("//span[text()='price']"))).click().build().perform(); 56 | 57 | driver.findElement(By.id("minPrice")).sendKeys("2000", Keys.TAB); 58 | 59 | driver.findElement(By.id("maxPrice")).sendKeys("5000", Keys.TAB); 60 | 61 | driver.findElement(By.xpath("(//button[@type='submit'])[2]")).click(); 62 | Thread.sleep(2000); 63 | 64 | driver.findElementByXPath("//img[@alt='Puma Red Shoulder Ferrari LS Shoulder Bag']").click(); 65 | Thread.sleep(4000); 66 | 67 | Set windowHandles = driver.getWindowHandles(); 68 | 69 | List newWindow = new ArrayList(windowHandles); 70 | 71 | WebDriver window = driver.switchTo().window(newWindow.get(1)); 72 | 73 | String rs = driver.findElementByXPath("//div[@class='prod-price-section']//div[@class='prod-sp']").getText(); 74 | 75 | String replaceAll = rs.replaceAll("\\D", ""); 76 | 77 | int productPrice = Integer.parseInt(replaceAll); 78 | 79 | String couponCode = driver.findElementByXPath("//div[@class='promo-title-blck']//div[text()='EPIC']").getText(); 80 | 81 | String discountPrice = driver.findElementByXPath("//div[@class='promo-discounted-price']//span[text()='2141']").getText(); 82 | 83 | String replaceAll2 = discountPrice.replaceAll("\\D", ""); 84 | 85 | int discountVal = Integer.parseInt(replaceAll2); 86 | 87 | if(productPrice >= 2690) { 88 | 89 | int disPrice = productPrice -discountVal; 90 | 91 | System.out.println("The discount price is :"+discountVal); 92 | } 93 | 94 | int disPrice = productPrice -discountVal; 95 | 96 | System.out.println("The final discount price is :"+disPrice ); 97 | 98 | WebDriverWait wait = new WebDriverWait(driver, 20); 99 | 100 | wait.until(ExpectedConditions.visibilityOf(driver.findElementByXPath("//span[text()='Enter pin-code to know estimated delivery date.']"))); 101 | 102 | driver.findElement(By.xpath("//span[text()='Enter pin-code to know estimated delivery date.']")).click(); 103 | 104 | driver.findElement(By.name("pincode")).sendKeys("560001"); 105 | 106 | driver.findElement(By.className("edd-pincode-modal-submit-btn")).click(); 107 | Thread.sleep(2000); 108 | 109 | driver.findElement(By.className("other-info-toggle")).click(); 110 | Thread.sleep(2000); 111 | 112 | String cusAddress = driver.findElementByXPath("(//span[@class='other-info'])[6]").getText(); 113 | 114 | System.out.println("Customer care address :"+ cusAddress); 115 | 116 | driver.findElement(By.xpath("//span[text()='ADD TO BAG']")).click(); 117 | Thread.sleep(5000); 118 | 119 | System.out.println("Added to the BAG"); 120 | 121 | wait.until(ExpectedConditions.elementToBeClickable(driver.findElementByXPath("//div[text()='PROCEED TO BAG']"))); 122 | 123 | driver.findElementByXPath("//div[text()='PROCEED TO BAG']").click(); 124 | 125 | String total = driver.findElementByXPath("//span[text()='Order Total']/following::span").getText().replaceAll("\\D", ""); 126 | 127 | System.out.println("The order total is :"+total ); 128 | 129 | driver.findElement(By.id("couponCodeInput")).sendKeys("EPIC"); 130 | 131 | driver.findElement(By.xpath("//button[text()='Apply']")).click(); 132 | Thread.sleep(2000); 133 | 134 | String rs1 = driver.findElement(By.xpath("(//span[@class='price-value discount-price'])[2]")).getText().substring(4); 135 | 136 | double parseDouble = Double.parseDouble(rs1); 137 | 138 | int round = (int) Math.round(parseDouble); 139 | 140 | System.out.println("The coupon saving is :"+ round); 141 | 142 | 143 | if(round == disPrice ) { 144 | 145 | System.out.println("Discount price matches"); 146 | } 147 | 148 | else { 149 | 150 | System.out.println("No match found"); 151 | } 152 | 153 | driver.findElement(By.className("delete-btn")).click(); 154 | Thread.sleep(2000); 155 | 156 | driver.findElement(By.xpath("(//div[@class='delete-btn'])[2]")).click(); 157 | Thread.sleep(2000); 158 | 159 | driver.quit(); 160 | 161 | System.out.println("***Run Successfull***"); 162 | 163 | 164 | 165 | 166 | } 167 | 168 | } 169 | -------------------------------------------------------------------------------- /BDD/Feature_file/Carwale.Feature: -------------------------------------------------------------------------------- 1 | 2 | Feature: Carwale 3 | Scenario: Carwale TC_001 4 | Given Open Carwale Site 5 | And Click on Used 6 | And Select the City as Chennai 7 | And Select budget min 8L and max 12L and Click Search 8 | And Select Cars with Photos under Only Show Cars With 9 | And Select Manufacturer as Hyundai Creta 10 | And Select Fuel Type as Petrol 11 | And Select Best Match as km low to high 12 | And Validate the Cars are listed with KMs Low to High 13 | And Add the least KM ran car to Wishlist 14 | When Go to Wishlist and Click on More Details 15 | Then Print all the details under Overview 16 | And Close the browser 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /BDD/RunnerFile/Carwale.runner: -------------------------------------------------------------------------------- 1 | package runner; 2 | 3 | import cucumber.api.CucumberOptions; 4 | import cucumber.api.SnippetType; 5 | import cucumber.api.testng.AbstractTestNGCucumberTests; 6 | 7 | @CucumberOptions(features = "src/test/java/feature", glue = "steps_defin", monochrome = true) 8 | 9 | public class RunnerFile extends AbstractTestNGCucumberTests { 10 | 11 | 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /BDD/Steps/Carwale.steps: -------------------------------------------------------------------------------- 1 | package steps_defin; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.LinkedHashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | import java.util.Set; 9 | import java.util.Map.Entry; 10 | import java.util.concurrent.TimeUnit; 11 | 12 | import org.openqa.selenium.By; 13 | import org.openqa.selenium.JavascriptExecutor; 14 | import org.openqa.selenium.Keys; 15 | import org.openqa.selenium.WebDriver; 16 | import org.openqa.selenium.WebElement; 17 | import org.openqa.selenium.chrome.ChromeDriver; 18 | import org.openqa.selenium.support.ui.ExpectedConditions; 19 | import org.openqa.selenium.support.ui.Select; 20 | import org.openqa.selenium.support.ui.WebDriverWait; 21 | 22 | import cucumber.api.java.en.And; 23 | import cucumber.api.java.en.Given; 24 | import cucumber.api.java.en.Then; 25 | import cucumber.api.java.en.When; 26 | 27 | public class Carwale_Steps { 28 | 29 | ChromeDriver driver; 30 | 31 | WebDriverWait wait; 32 | 33 | JavascriptExecutor executor; 34 | 35 | String strLeastKM = ""; 36 | 37 | 38 | @Given("Open Carwale Site") 39 | public void OpenCarwaleSite() { 40 | 41 | 42 | System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe"); 43 | 44 | driver = new ChromeDriver(); 45 | 46 | driver.get("https://www.carwale.com/"); 47 | 48 | driver.manage().window().maximize(); 49 | 50 | wait = new WebDriverWait(driver, 20); 51 | 52 | } 53 | 54 | @And("Click on Used") 55 | public void clickOnUsed() throws InterruptedException { 56 | 57 | driver.findElementByXPath("//li[@data-tabs='usedCars']").click(); 58 | Thread.sleep(2000); 59 | 60 | System.out.println("Selected Used Car"); 61 | 62 | wait.until(ExpectedConditions.elementToBeClickable(driver.findElementById("usedCarsList"))); 63 | } 64 | 65 | @And("Select the City as Chennai") 66 | public void selectTheCity() throws InterruptedException { 67 | 68 | driver.findElementById("usedCarsList").sendKeys("Chennai"); 69 | Thread.sleep(2000); 70 | 71 | driver.findElementByXPath("//a[@cityname='chennai,tamilnadu']").click(); 72 | Thread.sleep(2000); 73 | 74 | System.out.println("Entered the city name"); 75 | 76 | wait.until(ExpectedConditions.visibilityOf(driver.findElementById("minInput"))); 77 | 78 | } 79 | 80 | @And("Select budget min 8L and max 12L and Click Search") 81 | public void selectBudget() throws InterruptedException { 82 | 83 | driver.findElementById("minInput").sendKeys("8",Keys.TAB); 84 | Thread.sleep(2000); 85 | 86 | wait.until(ExpectedConditions.visibilityOf(driver.findElementById("maxInput"))); 87 | 88 | driver.findElementById("maxInput").sendKeys("12",Keys.TAB); 89 | 90 | driver.findElementById("btnFindCar").click(); 91 | 92 | } 93 | 94 | @And("Select Cars with Photos under Only Show Cars With") 95 | public void selectCarsWithPhotos() throws InterruptedException { 96 | 97 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 98 | 99 | driver.findElementByXPath("//span[text()='Cars with Photos']").click(); 100 | Thread.sleep(2000); 101 | 102 | System.out.println("Filter 1 applied"); 103 | } 104 | 105 | @And("Select Manufacturer as Hyundai Creta") 106 | public void selectCarModel() throws InterruptedException { 107 | 108 | WebElement Hyundai = driver.findElementByXPath("//ul[@id='makesList']//li[@data-manufacture-en='Hyundai']"); 109 | 110 | executor = (JavascriptExecutor)driver; 111 | executor.executeScript("arguments[0].scrollIntoView();", Hyundai); 112 | executor.executeScript("arguments[0].click();", Hyundai); 113 | 114 | WebElement Creta = driver.findElementByXPath("//ul[@class='rootUl']//span[text()='Creta']"); 115 | Thread.sleep(3000); 116 | 117 | executor.executeScript("arguments[0].scrollIntoView();", Creta); 118 | executor.executeScript("arguments[0].click();", Creta); 119 | 120 | System.out.println("Filter 2 applied"); 121 | 122 | 123 | } 124 | 125 | @And("Select Fuel Type as Petrol") 126 | public void selectFuelTypeAsPetrol() { 127 | 128 | WebElement FuelType = driver.findElementByXPath("//h3[contains(text(),'Fuel Type')]"); 129 | 130 | executor.executeScript("arguments[0].scrollIntoView();", FuelType); 131 | executor.executeScript("arguments[0].click();", FuelType); 132 | 133 | WebElement Petrol = driver.findElementByXPath("//li[@class='us-sprite']//span[text()='Petrol']"); 134 | 135 | 136 | executor.executeScript("arguments[0].scrollIntoView();", Petrol); 137 | executor.executeScript("arguments[0].click();", Petrol); 138 | 139 | System.out.println("Filter 3 applied"); 140 | 141 | 142 | } 143 | 144 | @And("Select Best Match as km low to high") 145 | public void selectBestMatch() throws InterruptedException { 146 | 147 | 148 | WebElement Filter = driver.findElement(By.id("sort")); 149 | 150 | Select dropDown = new Select(Filter); 151 | 152 | dropDown.selectByVisibleText("KM: Low to High"); 153 | Thread.sleep(2000); 154 | } 155 | 156 | @And("Validate the Cars are listed with KMs Low to High") 157 | public void validateTheCars() { 158 | 159 | Map leastKMSmap =new LinkedHashMap(); 160 | 161 | List kmsRan = driver.findElementsByXPath("//span[@class='slkms vehicle-data__item']"); 162 | 163 | List IntgrinKms = new ArrayList(); 164 | 165 | for (int i = 0; i < kmsRan.size(); i++) { 166 | 167 | String kmsText = kmsRan.get(i).getText(); 168 | 169 | String replaceAll = kmsText.replaceAll("\\D", ""); 170 | 171 | int KMS = Integer.parseInt(replaceAll); 172 | 173 | IntgrinKms.add(KMS); 174 | 175 | leastKMSmap.put(KMS, kmsText); 176 | 177 | } 178 | 179 | List SortedVehcle = new ArrayList(IntgrinKms); 180 | 181 | Collections.sort(SortedVehcle); 182 | 183 | if (IntgrinKms.equals(SortedVehcle)) { 184 | 185 | System.out.println("Vehicle's are sorted by KM"); 186 | } 187 | else { 188 | 189 | System.out.println("Vehicle's aren't sorted by KM"); 190 | } 191 | 192 | Integer leastKM = SortedVehcle.get(0); 193 | 194 | String strLeastKM = ""; 195 | 196 | for (Entry eachEntry : leastKMSmap.entrySet()) 197 | { 198 | if(eachEntry.getKey().equals(leastKM)) 199 | 200 | { 201 | strLeastKM = eachEntry.getValue(); 202 | } 203 | } 204 | 205 | 206 | } 207 | 208 | @And("Add the least KM ran car to Wishlist") 209 | public void addTheCar() throws InterruptedException { 210 | 211 | System.out.println("Least KM utilised by Hyundai Creta car: "+strLeastKM); 212 | Thread.sleep(1000); 213 | 214 | WebElement eleCarWishlist = driver.findElementByXPath("(//span[text()='"+strLeastKM+"']//ancestor::div[@class='stock-detail']//span[contains(@class,'shortlist')])[2]"); 215 | executor.executeScript("arguments[0].click();", eleCarWishlist); 216 | Thread.sleep(2000); 217 | 218 | driver.findElementByXPath("//li[@data-action='ShortList&CompareWindow_Click']").click(); 219 | Thread.sleep(2000); 220 | 221 | String carWithLeastKM = driver.findElementByXPath("//a[@data-action='ShortListedCar_Click']/span").getText(); 222 | 223 | System.out.println("Car which is a least KM: "+ carWithLeastKM); 224 | 225 | 226 | } 227 | 228 | @When("Go to Wishlist and Click on More Details") 229 | public void goToWishlist() throws InterruptedException { 230 | 231 | driver.findElementByXPath("//a[text()='More details »']").click(); 232 | Thread.sleep(3000); 233 | 234 | 235 | } 236 | 237 | @Then("Print all the details under Overview") 238 | public void printAllTheDetails() { 239 | 240 | Set newWindow = driver.getWindowHandles(); 241 | 242 | List WindowHandles = new ArrayList(newWindow); 243 | 244 | driver.switchTo().window(WindowHandles.get(1)); 245 | 246 | Map carDeets=new LinkedHashMap(); 247 | 248 | List eleDes = driver.findElementsByXPath("//div[contains(@class,'overview-list')]//div[contains(@class,'text-light-grey')]"); 249 | 250 | List eleValu = driver.findElementsByXPath("//div[contains(@class,'dark-text')]"); 251 | 252 | for(int i=0;i eachVal : carDeets.entrySet()) 263 | 264 | { 265 | System.out.println(eachVal.getKey()+ "----> " +eachVal.getValue()); 266 | } 267 | 268 | 269 | } 270 | 271 | @And("Close the browser") 272 | public void close() { 273 | 274 | driver.quit(); 275 | 276 | System.out.println("****Run Successful****"); 277 | 278 | } 279 | 280 | } 281 | -------------------------------------------------------------------------------- /Day11_Snapdeal: -------------------------------------------------------------------------------- 1 | package twentyOneDayChallenge; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import org.openqa.selenium.By; 6 | import org.openqa.selenium.Keys; 7 | import org.openqa.selenium.chrome.ChromeDriver; 8 | import org.openqa.selenium.interactions.Actions; 9 | 10 | public class Day11_SnapDeal { 11 | 12 | public static void main(String[] args) throws InterruptedException { 13 | 14 | 15 | System.setProperty("webdriver.chrome.driver", "./postman/chromedriver.exe"); 16 | 17 | ChromeDriver driver = new ChromeDriver(); 18 | 19 | driver.get("https://www.snapdeal.com/"); 20 | 21 | driver.manage().window().maximize(); 22 | 23 | System.out.println("Browser Opened"); 24 | 25 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 26 | 27 | Actions action = new Actions(driver); 28 | 29 | action.moveToElement(driver.findElementByXPath("//span[contains(text(),'Toys, Kids')]")).build().perform(); 30 | Thread.sleep(2000); 31 | 32 | System.out.println("Hovered to Toys & Kids Sextion"); 33 | 34 | driver.findElementByXPath("//span[contains(text(),'Educational Toys')]").click(); 35 | Thread.sleep(2000); 36 | 37 | System.out.println("Selected Educational Toys button"); 38 | 39 | driver.findElementByXPath("//div[@class='filters-list sdRadio ']//label[@for='avgRating-4.0']").click(); 40 | Thread.sleep(4000); 41 | 42 | System.out.println("Filter 1 applied"); 43 | 44 | driver.findElementByXPath("//div[@class='sdCheckbox filters-list ']//label[@for='discount-40%20-%2050']").click(); 45 | Thread.sleep(2000); 46 | 47 | System.out.println("Filter 2 applied"); 48 | 49 | driver.findElementByXPath("//div[@class='pincode-enter js-pincode-enter']//input[@placeholder='Enter your pincode']").sendKeys("600028", Keys.TAB); 50 | 51 | driver.findElementByXPath("//div[@class='pincode-enter js-pincode-enter']//button[text()='Check']").click(); 52 | Thread.sleep(2000); 53 | 54 | action.moveToElement(driver.findElementByXPath("(//img[@class='product-image wooble']//ancestor::div[@class='product-tuple-image ']//div[@class='clearfix row-disc'])[1]")).click().build().perform(); 55 | Thread.sleep(2000); 56 | 57 | driver.findElementByXPath("(//a[contains(@class,'btn btn-theme-secondary')])[1]").click(); 58 | 59 | String tabLET = driver.findElementByXPath("//span[@class='pdp-final-price']//span").getText(); 60 | 61 | String replaceAll = tabLET.replaceAll("\\D", ""); 62 | 63 | int tabletPrice = Integer.parseInt(replaceAll); 64 | 65 | System.out.println("The price of the Tablet is :"+ tabletPrice); 66 | 67 | String extraCharge = driver.findElementByXPath("(//span[@class='availCharges'])[2]").getText(); 68 | 69 | String replaceAll2 = extraCharge.replaceAll("\\D", ""); 70 | 71 | int additionalCharge = Integer.parseInt(replaceAll2); 72 | 73 | System.out.println("Transportation charge is :"+ additionalCharge); 74 | 75 | driver.findElementByXPath("//div[contains(@class,'col-xs-6 marR15 btn btn-xl')]//span[text()='add to cart']").click(); 76 | Thread.sleep(2000); 77 | 78 | System.out.println("Tablet added to the Cart"); 79 | 80 | String totalAmt = driver.findElementByXPath("//div[@class='you-pay']//span[@class='price']").getText(); 81 | 82 | String replaceAll3 = totalAmt.replaceAll("\\D", ""); 83 | 84 | int grandTotal = Integer.parseInt(replaceAll3); 85 | 86 | System.out.println("The grand total is :"+ grandTotal); 87 | 88 | if (tabletPrice + additionalCharge == grandTotal) { 89 | 90 | 91 | System.out.println("Product price amount matches"); 92 | } 93 | 94 | else { 95 | 96 | System.out.println("Product price doesn't match"); 97 | } 98 | 99 | driver.findElement(By.id("inputValEnter")).sendKeys("Sanitizer", Keys.ENTER); 100 | Thread.sleep(3000); 101 | 102 | System.out.println("Searched for Sanitizer"); 103 | 104 | action.moveToElement(driver.findElementByXPath("(//div[contains(@class,'col-xs-6')]//ancestor::div[@class='product-tuple-image ']//div[@class='clearfix row-disc'])[1]")).click().build().perform(); 105 | Thread.sleep(2000); 106 | 107 | driver.findElementByXPath("(//a[contains(@class,'btn btn-theme-secondary')])[1]").click(); 108 | 109 | String santiZER = driver.findElementByXPath("//span[@class='pdp-final-price']//span").getText(); 110 | 111 | String replaceAlls = santiZER.replaceAll("\\D", ""); 112 | 113 | int santizerAmt = Integer.parseInt(replaceAlls); 114 | 115 | System.out.println("The price of the Santizer is :"+ santizerAmt); 116 | 117 | String transAmt = driver.findElementByXPath("(//span[@class='availCharges'])[2]").getText(); 118 | 119 | String replaceAlls2 = transAmt.replaceAll("\\D", ""); 120 | 121 | int transportCharge = Integer.parseInt(replaceAlls2); 122 | 123 | System.out.println("Transportation charge is :"+ transportCharge); 124 | 125 | driver.findElementByClassName("adroll_consent_button").click(); 126 | 127 | driver.findElementByXPath("//div[@title='ADD TO CART']//span[text()='ADD TO CART']").click(); 128 | Thread.sleep(2000); 129 | 130 | System.out.println("Sanitizer added to the Cart"); 131 | 132 | driver.findElementByXPath("//div[@class='cartInner']//span[text()='Cart']").click(); 133 | Thread.sleep(3000); 134 | 135 | System.out.println("Tapped on the Cart"); 136 | 137 | String totalCharge = driver.findElementByXPath("(//div[@class='cart-collapsed']//span[@class='item-subtotal-black'])[2]").getText(); 138 | 139 | String replaceAlls3 = totalCharge.replaceAll("\\D", ""); 140 | 141 | int grandTotal2 = Integer.parseInt(replaceAlls3); 142 | 143 | System.out.println("The grand total for second product is :"+ grandTotal2); 144 | 145 | if (santizerAmt + transportCharge == grandTotal2) { 146 | 147 | 148 | System.out.println("Second Product price amount matches"); 149 | } 150 | 151 | else { 152 | 153 | System.out.println("Product price doesn't match"); 154 | } 155 | Thread.sleep(3000); 156 | String allTotal = driver.findElementByXPath("//input[@type='button']").getAttribute("value"); 157 | 158 | String replaceAll4 = allTotal.replaceAll("\\D", ""); 159 | 160 | int totalOf2Prduct = Integer.parseInt(replaceAll4); 161 | 162 | System.out.println("The total of two product is :"+ totalOf2Prduct); 163 | 164 | 165 | if(grandTotal + grandTotal2 == totalOf2Prduct) { 166 | 167 | System.out.println("Total product price matches"); 168 | } 169 | 170 | else { 171 | 172 | System.out.println("Total product price doesn't match"); 173 | } 174 | 175 | driver.close(); 176 | 177 | System.out.println("***Run successful***"); 178 | } 179 | 180 | } 181 | 182 | -------------------------------------------------------------------------------- /Day12_Carwale: -------------------------------------------------------------------------------- 1 | package twentyOneDayChallenge; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.LinkedHashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | import java.util.Map.Entry; 9 | import java.util.Set; 10 | import java.util.concurrent.TimeUnit; 11 | 12 | import org.openqa.selenium.By; 13 | import org.openqa.selenium.JavascriptExecutor; 14 | import org.openqa.selenium.Keys; 15 | import org.openqa.selenium.WebElement; 16 | import org.openqa.selenium.chrome.ChromeDriver; 17 | import org.openqa.selenium.interactions.Actions;import org.openqa.selenium.support.ui.ExpectedConditions; 18 | import org.openqa.selenium.support.ui.Select; 19 | import org.openqa.selenium.support.ui.Wait; 20 | import org.openqa.selenium.support.ui.WebDriverWait; 21 | 22 | public class Day12Carwale { 23 | 24 | public static void main(String[] args) throws InterruptedException { 25 | 26 | 27 | System.setProperty("webdriver.chrome.driver", "./postman/chromedriver.exe"); 28 | 29 | ChromeDriver driver = new ChromeDriver(); 30 | 31 | driver.get("https://www.carwale.com/"); 32 | 33 | driver.manage().window().maximize(); 34 | 35 | WebDriverWait wait = new WebDriverWait(driver, 20); 36 | 37 | driver.findElementByXPath("//li[@data-tabs='usedCars']").click(); 38 | Thread.sleep(2000); 39 | 40 | System.out.println("Selected Used Car"); 41 | 42 | wait.until(ExpectedConditions.elementToBeClickable(driver.findElementById("usedCarsList"))); 43 | 44 | driver.findElementById("usedCarsList").sendKeys("Chennai"); 45 | Thread.sleep(2000); 46 | 47 | driver.findElementByXPath("//a[@cityname='chennai,tamilnadu']").click(); 48 | Thread.sleep(2000); 49 | 50 | System.out.println("Entered the city name"); 51 | 52 | wait.until(ExpectedConditions.visibilityOf(driver.findElementById("minInput"))); 53 | 54 | driver.findElementById("minInput").sendKeys("8",Keys.TAB); 55 | Thread.sleep(2000); 56 | 57 | wait.until(ExpectedConditions.visibilityOf(driver.findElementById("maxInput"))); 58 | 59 | driver.findElementById("maxInput").sendKeys("12",Keys.TAB); 60 | 61 | driver.findElementById("btnFindCar").click(); 62 | 63 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 64 | 65 | driver.findElementByXPath("//span[text()='Cars with Photos']").click(); 66 | Thread.sleep(2000); 67 | 68 | System.out.println("Filter 1 applied"); 69 | 70 | 71 | 72 | WebElement Hyundai = driver.findElementByXPath("//ul[@id='makesList']//li[@data-manufacture-en='Hyundai']"); 73 | 74 | JavascriptExecutor executor = (JavascriptExecutor)driver; 75 | executor.executeScript("arguments[0].scrollIntoView();", Hyundai); 76 | executor.executeScript("arguments[0].click();", Hyundai); 77 | 78 | WebElement Creta = driver.findElementByXPath("//ul[@class='rootUl']//span[text()='Creta']"); 79 | Thread.sleep(3000); 80 | 81 | executor.executeScript("arguments[0].scrollIntoView();", Creta); 82 | executor.executeScript("arguments[0].click();", Creta); 83 | 84 | System.out.println("Filter 2 applied"); 85 | 86 | WebElement FuelType = driver.findElementByXPath("//h3[contains(text(),'Fuel Type')]"); 87 | 88 | executor.executeScript("arguments[0].scrollIntoView();", FuelType); 89 | executor.executeScript("arguments[0].click();", FuelType); 90 | 91 | WebElement Petrol = driver.findElementByXPath("//li[@class='us-sprite']//span[text()='Petrol']"); 92 | 93 | 94 | executor.executeScript("arguments[0].scrollIntoView();", Petrol); 95 | executor.executeScript("arguments[0].click();", Petrol); 96 | 97 | System.out.println("Filter 3 applied"); 98 | 99 | WebElement Filter = driver.findElement(By.id("sort")); 100 | 101 | Select dropDown = new Select(Filter); 102 | 103 | dropDown.selectByVisibleText("KM: Low to High"); 104 | Thread.sleep(2000); 105 | 106 | Map leastKMSmap =new LinkedHashMap(); 107 | 108 | List kmsRan = driver.findElementsByXPath("//span[@class='slkms vehicle-data__item']"); 109 | 110 | List IntgrinKms = new ArrayList(); 111 | 112 | for (int i = 0; i < kmsRan.size(); i++) { 113 | 114 | String kmsText = kmsRan.get(i).getText(); 115 | 116 | String replaceAll = kmsText.replaceAll("\\D", ""); 117 | 118 | int KMS = Integer.parseInt(replaceAll); 119 | 120 | IntgrinKms.add(KMS); 121 | 122 | leastKMSmap.put(KMS, kmsText); 123 | 124 | } 125 | 126 | List SortedVehcle = new ArrayList(IntgrinKms); 127 | 128 | Collections.sort(SortedVehcle); 129 | 130 | if (IntgrinKms.equals(SortedVehcle)) { 131 | 132 | System.out.println("Vehicle's are sorted by KM"); 133 | } 134 | else { 135 | 136 | System.out.println("Vehicle's aren't sorted by KM"); 137 | } 138 | 139 | Integer leastKM = SortedVehcle.get(0); 140 | 141 | String strLeastKM = ""; 142 | 143 | for (Entry eachEntry : leastKMSmap.entrySet()) 144 | { 145 | if(eachEntry.getKey().equals(leastKM)) 146 | { 147 | strLeastKM = eachEntry.getValue(); 148 | } 149 | } 150 | System.out.println("Least KM utilised by Hyundai Creta car: "+strLeastKM); 151 | Thread.sleep(1000); 152 | 153 | WebElement eleCarWishlist = driver.findElementByXPath("(//span[text()='"+strLeastKM+"']//ancestor::div[@class='stock-detail']//span[contains(@class,'shortlist')])[2]"); 154 | executor.executeScript("arguments[0].click();", eleCarWishlist); 155 | Thread.sleep(2000); 156 | 157 | driver.findElementByXPath("//li[@data-action='ShortList&CompareWindow_Click']").click(); 158 | Thread.sleep(2000); 159 | 160 | String carWithLeastKM = driver.findElementByXPath("//a[@data-action='ShortListedCar_Click']/span").getText(); 161 | 162 | System.out.println("Car which is a least KM: "+ carWithLeastKM); 163 | 164 | driver.findElementByXPath("//a[text()='More details »']").click(); 165 | Thread.sleep(3000); 166 | 167 | 168 | Set newWindow = driver.getWindowHandles(); 169 | 170 | List WindowHandles = new ArrayList(newWindow); 171 | 172 | driver.switchTo().window(WindowHandles.get(1)); 173 | 174 | Map carDeets=new LinkedHashMap(); 175 | 176 | List eleDes = driver.findElementsByXPath("//div[contains(@class,'overview-list')]//div[contains(@class,'text-light-grey')]"); 177 | 178 | List eleValu = driver.findElementsByXPath("//div[contains(@class,'dark-text')]"); 179 | 180 | for(int i=0;i eachVal : carDeets.entrySet()) 191 | 192 | { 193 | System.out.println(eachVal.getKey()+ "----> " +eachVal.getValue()); 194 | } 195 | 196 | 197 | driver.quit(); 198 | } 199 | 200 | } 201 | -------------------------------------------------------------------------------- /Day13_Shiksha: -------------------------------------------------------------------------------- 1 | package twentyOneDayChallenge; 2 | 3 | import java.util.List; 4 | 5 | import org.openqa.selenium.WebElement; 6 | import org.openqa.selenium.chrome.ChromeDriver; 7 | import org.openqa.selenium.interactions.Actions; 8 | import org.openqa.selenium.support.ui.ExpectedConditions; 9 | import org.openqa.selenium.support.ui.Select; 10 | import org.openqa.selenium.support.ui.WebDriverWait; 11 | 12 | public class Day13_Shiksha { 13 | 14 | public static void main(String[] args) throws InterruptedException { 15 | 16 | System.setProperty("webdriver.chrome.driver", "./postman/chromedriver.exe"); 17 | 18 | ChromeDriver driver = new ChromeDriver(); 19 | 20 | driver.get("https://studyabroad.shiksha.com/"); 21 | 22 | driver.manage().window().maximize(); 23 | 24 | WebDriverWait wait = new WebDriverWait(driver, 10); 25 | 26 | Actions action = new Actions(driver); 27 | 28 | WebElement mouseOver = driver.findElementByXPath("//label[text()='Colleges ']"); 29 | 30 | action.moveToElement(mouseOver).build().perform(); 31 | Thread.sleep(1000); 32 | 33 | System.out.println("Mouse hovered"); 34 | 35 | WebElement cliCK = driver.findElementByXPath("//a[text()='MS in Computer Science &Engg']"); 36 | 37 | action.moveToElement(cliCK).click().build().perform(); 38 | 39 | System.out.println("Tapped on MS Colleges button"); 40 | 41 | driver.findElementByClassName("cookAgr-btn").click(); 42 | Thread.sleep(3000); 43 | 44 | System.out.println("Cookies have been accepted"); 45 | 46 | driver.findElementByXPath("//label[@class='exam-col-chkbx flLt']//span[@class='common-sprite']").click(); 47 | Thread.sleep(1000); 48 | 49 | System.out.println("Selected Exam Accepted"); 50 | 51 | WebElement marksFilter = driver.findElementByXPath("//div[@class='filter-dropdown flLt']//select[@class='score-select-field']"); 52 | 53 | Select dropDown = new Select(marksFilter); 54 | 55 | dropDown.selectByVisibleText("300 & below"); 56 | Thread.sleep(2000); 57 | 58 | System.out.println("Mark's selected"); 59 | 60 | driver.findElementByXPath("(//label//span[@class='common-sprite'])[37]").click(); 61 | Thread.sleep(1000); 62 | 63 | System.out.println("1st Year Total Fees"); 64 | 65 | driver.findElementByXPath("(//label//span[@class='common-sprite'])[50]").click(); 66 | Thread.sleep(2000); 67 | 68 | System.out.println("Selected Country"); 69 | 70 | WebElement Filter = driver.findElementById("categorySorter"); 71 | 72 | Select dropDown2 = new Select(Filter); 73 | 74 | dropDown2.selectByVisibleText("Low to high 1st year total fees"); 75 | Thread.sleep(2000); 76 | 77 | System.out.println("Filter have been applied"); 78 | 79 | driver.findElementByXPath("(//span[@class='common-sprite'])[77]").click(); 80 | Thread.sleep(2000); 81 | 82 | System.out.println("Added to compare"); 83 | 84 | driver.findElementByXPath("//a[text()=' Texas Southern University']").click(); 85 | 86 | driver.findElementByXPath("//div[@id='compareCourseBottomLayer']//a[@class='button-style']").click(); 87 | Thread.sleep(2000); 88 | 89 | System.out.println("Tapped on compare button"); 90 | 91 | driver.findElementByXPath("//label[@for='year1']//span[@class='common-sprite']").click(); 92 | 93 | System.out.println("Selected the year of study"); 94 | 95 | action.moveToElement(driver.findElementByXPath("//div[contains(@class,'sp-frm selectCountryField')]//div[text()='Preferred Countries']")).click().build().perform(); 96 | 97 | driver.findElementByXPath("(//label[@class='nolnht']//span[@class='common-sprite'])[1]").click(); 98 | 99 | driver.findElementByXPath("//div[@class='choose-count']//a[text()='ok']").click(); 100 | Thread.sleep(2000); 101 | 102 | System.out.println("Selected Preferred country"); 103 | 104 | driver.findElementByXPath("//label[contains(@for,'Masters')]//span[@class='common-sprite']").click(); 105 | 106 | action.moveToElement(driver.findElementByXPath("//div[contains(@class,'signUp-child-wrap')]//div[text()='Preferred Course']")).click().build().perform(); 107 | 108 | action.moveToElement(driver.findElementByXPath("//ul//li[text()='MS']")).click().build().perform(); 109 | Thread.sleep(2000); 110 | 111 | action.moveToElement(driver.findElementByXPath("(//div[@class='placeholder'])[3]")).click().build().perform(); 112 | 113 | action.moveToElement(driver.findElementByXPath("//li[text()='Computer Science & Engineering']")).click().build().perform(); 114 | Thread.sleep(2000); 115 | 116 | driver.findElementByXPath("//div[@class='sp-btn']//a[contains(text(),'Sign Up')]").click(); 117 | 118 | System.out.println("Tapped on Sign Up button"); 119 | 120 | List errorMSG = driver.findElementsByXPath("//div[@class='helper-text' and starts-with(text(),'Please')]"); 121 | 122 | System.out.println("The error messages are displayed below :"); 123 | 124 | System.out.println("-------------------------------"); 125 | 126 | for (WebElement errorMessage : errorMSG) 127 | { 128 | { 129 | if(errorMessage.getText().length()>0) 130 | { 131 | System.out.println(errorMessage.getText()); 132 | } 133 | } 134 | 135 | } 136 | 137 | driver.close(); 138 | } 139 | 140 | } 141 | 142 | -------------------------------------------------------------------------------- /Day14_Zalando: -------------------------------------------------------------------------------- 1 | package twentyOneDayChallenge; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.NoSuchElementException; 6 | import java.util.Set; 7 | import java.util.concurrent.TimeUnit; 8 | 9 | import org.openqa.selenium.Alert; 10 | import org.openqa.selenium.Keys; 11 | import org.openqa.selenium.WebElement; 12 | import org.openqa.selenium.chrome.ChromeDriver; 13 | import org.openqa.selenium.interactions.Actions; 14 | import org.openqa.selenium.support.ui.ExpectedConditions; 15 | import org.openqa.selenium.support.ui.WebDriverWait; 16 | 17 | public class Day14_Zalando { 18 | 19 | public static void main(String [] args) throws InterruptedException { 20 | 21 | System.setProperty("webdriver.chrome.driver", "./postman/chromedriver.exe"); 22 | 23 | ChromeDriver driver = new ChromeDriver(); 24 | 25 | driver.get("https://www.zalando.co.uk/faq/Delivery/Do-delivery-and-returns-cost-anything.html"); 26 | 27 | driver.manage().window().maximize(); 28 | 29 | driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); 30 | 31 | Alert alert = driver.switchTo().alert(); 32 | 33 | String alertText = alert.getText(); 34 | 35 | System.out.println("Alert text : "+ alertText); 36 | 37 | alert.accept(); 38 | 39 | System.out.println("Alert has been accepted"); 40 | 41 | Actions action = new Actions(driver); 42 | 43 | WebElement zalandoUK = driver.findElementByXPath("//a[text()='Zalando.uk']"); 44 | 45 | action.moveToElement(zalandoUK).click().build().perform(); 46 | Thread.sleep(4000); 47 | 48 | System.out.println("Moved to Zalando.UK Site"); 49 | 50 | try { 51 | 52 | driver.findElementByXPath("//button[contains(@class,'uc-btn-primary')]").click(); 53 | 54 | System.out.println("Cookies have been accepted"); 55 | } 56 | 57 | catch (NoSuchElementException e) { 58 | 59 | } 60 | 61 | action.moveToElement(driver.findElementByXPath("//a[@class='z-navicat-header_gender']//span[text()='Women']")).click().build().perform(); 62 | 63 | System.out.println("Clicked Women button"); 64 | 65 | action.moveToElement(driver.findElementByXPath("//a[@class='z-navicat-header_categoryListLink']//span[text()='Clothing']")).build().perform(); 66 | Thread.sleep(2000); 67 | 68 | driver.findElementByXPath("//span[text()='Coats']").click(); 69 | 70 | System.out.println("Clicked Coats button"); 71 | 72 | action.moveToElement(driver.findElementByXPath("//button[@aria-label='filter by Material']//span[text()='Material']")).click().build().perform(); 73 | 74 | action.moveToElement(driver.findElementByXPath("//li[@role='checkbox']//span[text()='cotton (100%)']")).click().build().perform(); 75 | 76 | driver.findElementByXPath("//button[text()='Save']").click(); 77 | Thread.sleep(2000); 78 | 79 | System.out.println("First filter applied"); 80 | 81 | action.moveToElement(driver.findElementByXPath("//button[@aria-label='filter by Length']//span[text()='Length']")).click().build().perform(); 82 | 83 | action.moveToElement(driver.findElementByXPath("//li[@role='checkbox']//span[text()='thigh-length']")).click().build().perform(); 84 | 85 | driver.findElementByXPath("//button[text()='Save']").click(); 86 | Thread.sleep(2000); 87 | 88 | System.out.println("Second filter applied"); 89 | 90 | driver.findElementByXPath("//img[@alt='MANTEL - Parka - navy']").click(); 91 | Thread.sleep(2000); 92 | 93 | driver.findElementByXPath("(//img[@alt='olive'])[2]").click(); 94 | 95 | String oliVE = driver.findElementByXPath("//h2[text()='Out of stock']").getText(); 96 | 97 | if(oliVE.contains("Out of stock")) { 98 | 99 | driver.findElementByXPath("(//img[@alt='navy'])[2]").click(); 100 | Thread.sleep(2000); 101 | 102 | action.moveToElement(driver.findElementByXPath("//button[@aria-label='Choose your size']//span[text()='Choose your size']")).click().build().perform(); 103 | 104 | action.moveToElement(driver.findElementByXPath("//span[text()='M']")).click().build().perform(); 105 | 106 | System.out.println("Selected Size"); 107 | 108 | } 109 | 110 | String textFree = driver.findElementByXPath("(//button[@aria-label='Free']//span)[1]").getText(); 111 | 112 | if(textFree.contains("Free")) { 113 | 114 | driver.findElementByXPath("//button[@aria-label='Add to bag']//span[text()='Add to bag']").click(); 115 | Thread.sleep(2000); 116 | 117 | System.out.println("Added to the bag"); 118 | } 119 | 120 | action.moveToElement(driver.findElementByXPath("//a[@class='z-navicat-header_navToolItemLink']")).build().perform(); 121 | Thread.sleep(2000); 122 | 123 | System.out.println("Hoverd to Add to bag"); 124 | 125 | driver.findElementByXPath("//div[text()='Go to bag']").click(); 126 | Thread.sleep(2000); 127 | 128 | String DT = driver.findElementByXPath("//div[@data-id='delivery-estimation']//span").getText(); 129 | 130 | System.out.println("The estimated date and time is :"+ DT); 131 | 132 | action.moveToElement(driver.findElementByXPath("//a[text()='Free delivery & returns*']")).click().build().perform(); 133 | Thread.sleep(4000); 134 | 135 | System.out.println("Free delivery & returns"); 136 | 137 | WebDriverWait wait = new WebDriverWait(driver, 20); 138 | 139 | wait.until(ExpectedConditions.visibilityOf(driver.findElementByXPath("//span[text()='Start chat']"))); 140 | 141 | Thread.sleep(2000); 142 | 143 | driver.findElementByXPath("//span[text()='Start chat']").click(); 144 | 145 | Set windowHandles = driver.getWindowHandles(); 146 | 147 | List lstwindowHandles = new ArrayList(windowHandles); 148 | 149 | driver.switchTo().window(lstwindowHandles.get(1)); 150 | 151 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 152 | 153 | System.out.println("Moved to the new window"); 154 | 155 | driver.findElementById("prechat_customer_name_id").sendKeys("vivekaka", Keys.TAB); 156 | 157 | driver.findElementById("prechat_customer_email_id").sendKeys("otango@gmail.com", Keys.TAB); 158 | 159 | driver.findElementById("prechat_submit").click(); 160 | Thread.sleep(3000); 161 | 162 | driver.findElementByXPath("//textarea[@class='liveAgentChatTextArea']").sendKeys("Hi", Keys.ENTER); 163 | 164 | String replyFrombot = driver.findElementByXPath("//span[@class='operator']//span[contains(text(),'Hi there! How')]").getText(); 165 | 166 | System.out.println("Bot reply is : "+replyFrombot); 167 | 168 | driver.close(); 169 | 170 | System.out.println("***Run successfull***"); 171 | 172 | } 173 | 174 | } 175 | -------------------------------------------------------------------------------- /Day6_Bigbasket: -------------------------------------------------------------------------------- 1 | package twentyOneDayChallenge; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import org.openqa.selenium.By; 6 | import org.openqa.selenium.Keys; 7 | import org.openqa.selenium.WebElement; 8 | import org.openqa.selenium.chrome.ChromeDriver; 9 | import org.openqa.selenium.interactions.Actions; 10 | import org.openqa.selenium.support.ui.WebDriverWait; 11 | import org.testng.Assert; 12 | 13 | public class Day6_Bigbasket { 14 | 15 | public static void main(String[] args) throws InterruptedException { 16 | 17 | System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe"); 18 | 19 | ChromeDriver driver = new ChromeDriver(); 20 | 21 | driver.get("https://www.bigbasket.com/"); 22 | 23 | driver.manage().window().maximize(); 24 | 25 | WebDriverWait wait = new WebDriverWait(driver, 20); 26 | 27 | Actions action = new Actions(driver); 28 | 29 | action.moveToElement(driver.findElement(By.xpath("//li[@class='dropdown full-wid hvr-drop']"))).build().perform(); 30 | Thread.sleep(2000); 31 | 32 | System.out.println("Shop by category"); 33 | 34 | action.moveToElement(driver.findElement(By.xpath("(//a[text()='Foodgrains, Oil & Masala'])[2]"))).build().perform(); 35 | Thread.sleep(2000); 36 | 37 | System.out.println("Foodgrains, Oil & Masala"); 38 | 39 | action.moveToElement(driver.findElementByXPath("(//li[@class='ng-scope']//a[text()='Rice & Rice Products'])[2]")).build().perform(); 40 | Thread.sleep(4000); 41 | 42 | System.out.println("Rice & Rice Products"); 43 | 44 | action.moveToElement(driver.findElementByXPath("(//li[@class='ng-scope']//a[text()='Boiled & Steam Rice'])[2]")).click().build().perform(); 45 | 46 | System.out.println("Boiled & Steam Rice"); 47 | 48 | WebDriverWait waits = new WebDriverWait(driver, 20); 49 | 50 | driver.findElementByXPath("//span[text()='bb Royal']").click(); 51 | Thread.sleep(3000); 52 | 53 | System.out.println("bb Royal"); 54 | 55 | driver.findElementByXPath("//a[text()='Ponni Boiled Rice - Super Premium']/ancestor::div[@class='item prod-deck row ng-scope']//button[@class='btn btn-default dropdown-toggle form-control']").click(); 56 | 57 | driver.findElementByXPath("//a[text()='Ponni Boiled Rice - Super Premium']/ancestor::div[@class='item prod-deck row ng-scope']//ul[@class='dropdown-menu drop-select']//span[text()='5 kg']").click(); 58 | 59 | System.out.println("Slected 5kg in Ponni brand"); 60 | 61 | String ponniPrice = driver.findElementByXPath("//a[text()='Ponni Boiled Rice - Super Premium']/ancestor::div[@class='item prod-deck row ng-scope']//span[@class='discnt-price']").getText(); 62 | 63 | String replaceAll = ponniPrice.replaceAll("\\D", ""); 64 | 65 | int ponniAmt = Integer.parseInt(replaceAll); 66 | 67 | System.out.println(ponniAmt); 68 | 69 | driver.findElementByXPath("//a[text()='Ponni Boiled Rice - Super Premium']/ancestor::div[@class='item prod-deck row ng-scope']//button[contains(text(),'Add')]").click(); 70 | Thread.sleep(2000); 71 | 72 | System.out.println("Added to the cart"); 73 | 74 | driver.findElement(By.xpath("(//a[@qa='continueBtn'])[1]")).click(); 75 | 76 | driver.findElementByXPath("//input[@placeholder='Search for Products..']").sendKeys("Dal", Keys.ENTER); 77 | Thread.sleep(3000); 78 | 79 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 80 | 81 | driver.findElementByXPath("//a[text()='Toor/Arhar Dal/Thuvaram Paruppu']/ancestor::div[@class='item prod-deck row ng-scope']//button[@class='btn btn-default dropdown-toggle form-control']").click(); 82 | Thread.sleep(3000); 83 | 84 | driver.findElementByXPath("//a[text()='Toor/Arhar Dal/Thuvaram Paruppu']/ancestor::div[@class='item prod-deck row ng-scope']//ul//span[text()='2 kg']").click(); 85 | Thread.sleep(2000); 86 | 87 | System.out.println("Selected 2Kg in Toor-Dhal"); 88 | 89 | WebElement element = driver.findElementByXPath("//a[text()='Toor/Arhar Dal/Thuvaram Paruppu']/ancestor::div[@class='item prod-deck row ng-scope']//input[@class='form-control ng-pristine ng-untouched ng-valid ng-not-empty ng-valid-maxlength']"); 90 | element.clear(); 91 | 92 | element.sendKeys("2"); 93 | 94 | String Toordhal = driver.findElementByXPath("//a[text()='Toor/Arhar Dal/Thuvaram Paruppu']/ancestor::div[@class='item prod-deck row ng-scope']//span[@class='discnt-price']/span").getText(); 95 | 96 | String replaceAll2 = Toordhal.replaceAll("\\D", ""); 97 | 98 | int ToorDhalPrice = Integer.parseInt(replaceAll2); 99 | 100 | System.out.println(ToorDhalPrice); 101 | 102 | driver.findElementByXPath("(//button[@qa='add'])[6]").click(); 103 | 104 | driver.findElementByXPath("//a[text()='Toor/Arhar Dal/Thuvaram Paruppu']/ancestor::div[@class='item prod-deck row ng-scope']//button[contains(text(),'Add')]").click(); 105 | 106 | System.out.println("Dhal added to the craft"); 107 | 108 | Thread.sleep(3000); 109 | 110 | String successMsg = driver.findElementByXPath(("//button[@role='button']/following-sibling::div[1]")).getText(); 111 | 112 | System.out.println(successMsg); 113 | 114 | action.moveToElement(driver.findElementByXPath("//span[@class='basket-content']")).build().perform(); 115 | 116 | System.out.println("Moved cusror over My Basket"); 117 | 118 | String subTotal = driver.findElementByXPath("//div[@class='row sub-cost ng-scope']//span[@class='ng-binding']").getText(); 119 | 120 | int Total = ponniAmt + (ToorDhalPrice * 2); 121 | 122 | System.out.println("Sub Total : "+ subTotal); 123 | 124 | System.out.println("Total : "+ Total); 125 | 126 | int intSub = Integer.parseInt(subTotal.replaceAll("\\D", "")); 127 | 128 | Assert.assertEquals(Total, intSub); 129 | 130 | System.out.println("Total Matches"); 131 | 132 | driver.findElementByXPath("(//div[@class='btn-counter row']//button)[3]").click(); 133 | 134 | subTotal = driver.findElementByXPath("//div[@class='row sub-cost ng-scope']//p//span//span").getText(); 135 | 136 | Total = ponniAmt + ToorDhalPrice; 137 | 138 | System.out.println("Sub total : "+ subTotal); 139 | 140 | System.out.println("Total : "+ Total); 141 | 142 | intSub = Integer.parseInt(subTotal.replaceAll("\\D", "")); 143 | 144 | Assert.assertEquals(Total, intSub); 145 | 146 | System.out.println("Total Mathes"); 147 | 148 | driver.close(); 149 | 150 | 151 | } 152 | 153 | 154 | } 155 | -------------------------------------------------------------------------------- /Day7_BikeStore: -------------------------------------------------------------------------------- 1 | package twentyOneDayChallenge; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Set; 6 | import java.util.concurrent.TimeUnit; 7 | 8 | import org.openqa.selenium.By; 9 | import org.openqa.selenium.WebDriver; 10 | import org.openqa.selenium.WebElement; 11 | import org.openqa.selenium.chrome.ChromeDriver; 12 | import org.openqa.selenium.interactions.Actions; 13 | import org.openqa.selenium.support.ui.Select; 14 | 15 | public class Day7_BikeStore { 16 | 17 | public static void main(String[] args) throws InterruptedException { 18 | 19 | System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe"); 20 | 21 | ChromeDriver driver = new ChromeDriver(); 22 | 23 | driver.get(" https://www.honda2wheelersindia.com/"); 24 | 25 | driver.manage().window().maximize(); 26 | 27 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 28 | 29 | driver.findElementByXPath("//button[@class='close']").click(); 30 | 31 | driver.findElementByXPath("//a[text()='Scooter']").click(); 32 | Thread.sleep(2000); 33 | 34 | System.out.println("Clicked Scooter"); 35 | 36 | driver.findElement(By.xpath("(//div[@class='item']//img)[4]")).click(); 37 | 38 | System.out.println("Clicked Dio bike"); 39 | 40 | driver.findElementByXPath("//a[text()='Specifications']").click(); 41 | 42 | System.out.println("Clicked Specifications for Dio"); 43 | 44 | Actions action = new Actions(driver); 45 | 46 | action.moveToElement(driver.findElementByXPath("//a[text()='ENGINE']")).build().perform(); 47 | Thread.sleep(2000); 48 | 49 | String displacementValue = driver.findElementByXPath("(//ul[@class='tab_content']//span[text()='109.51cc'])").getText(); 50 | 51 | System.out.println(displacementValue); 52 | 53 | float DisplacementVal1 = Float.parseFloat(displacementValue.replaceAll("c", "")); 54 | 55 | System.out.println(DisplacementVal1); 56 | 57 | driver.findElement(By.id("link_Scooter")).click(); 58 | 59 | driver.findElement(By.xpath("(//div[@class='item']//img)[6]")).click(); 60 | 61 | System.out.println("Clicked Activa"); 62 | 63 | driver.findElementByXPath("//a[text()='Specifications']").click(); 64 | 65 | System.out.println("Clicked Specifications for Activa"); 66 | 67 | action.moveToElement(driver.findElementByXPath("//a[text()='ENGINE']")).build().perform(); 68 | Thread.sleep(4000); 69 | 70 | String disValActiva = driver.findElementByXPath("(//ul[@class='tab_content']//span[text()='124 cc'])").getText(); 71 | 72 | System.out.println(disValActiva); 73 | 74 | float DisplacementVal2= Float.parseFloat(displacementValue.replaceAll("c", "")); 75 | 76 | System.out.println(DisplacementVal2); 77 | 78 | if (DisplacementVal1 > DisplacementVal2) { 79 | System.out.println("Dio has the greater Displacement"); 80 | } 81 | else { 82 | System.out.println("Activa has the greater Displacement"); 83 | } 84 | 85 | driver.findElementByXPath("//a[text()='FAQ']").click(); 86 | Thread.sleep(4000); 87 | 88 | System.out.println("Selected FAQ Link"); 89 | 90 | String textSelect = driver.findElementByXPath("//a[text()='Activa 125 BS-VI']").getText(); 91 | 92 | driver.findElementByXPath("//a[text()='Activa 125 BS-VI']").click(); 93 | Thread.sleep(2000); 94 | 95 | System.out.println(textSelect); 96 | 97 | driver.findElementByXPath("(//a[@data-toggle='tab']//i)[6]").click(); 98 | Thread.sleep(3000); 99 | 100 | System.out.println("Clicked Vehicle Price"); 101 | 102 | String textSelect2 = driver.findElementByXPath("(//select[@id='ModelID6']//option)[4]").getText(); 103 | 104 | System.out.println(textSelect2); 105 | 106 | if(textSelect.contains(textSelect2)) { 107 | 108 | driver.findElementByXPath("(//button[text()='Submit'])[6]").click(); 109 | Thread.sleep(2000); 110 | 111 | System.out.println("Clicked Submit Button"); 112 | 113 | driver.findElementByXPath("//a[text()='Click here to know the price of Activa 125 BS-VI.']").click(); 114 | Thread.sleep(2000); 115 | 116 | System.out.println("To know the Price"); 117 | 118 | Set windowHandles = driver.getWindowHandles(); 119 | 120 | List newWindow = new ArrayList(windowHandles); 121 | 122 | WebDriver window1 = driver.switchTo().window(newWindow.get(1)); 123 | 124 | System.out.println("Moved to the new window"); 125 | 126 | WebElement drop = driver.findElementById("StateID"); 127 | 128 | Select dropDown = new Select(drop); 129 | 130 | dropDown.selectByVisibleText("Tamil Nadu"); 131 | Thread.sleep(4000); 132 | 133 | System.out.println("Selected State"); 134 | 135 | WebElement drop2 = driver.findElementById("CityID"); 136 | 137 | Select citySelect = new Select(drop2); 138 | 139 | citySelect.selectByVisibleText("Chennai"); 140 | 141 | System.out.println("Selected City"); 142 | 143 | driver.findElementByXPath("//button[text()='Search']").click(); 144 | Thread.sleep(2000); 145 | 146 | System.out.println("Submitted to know the Bike Price's"); 147 | 148 | WebElement table = driver.findElement(By.id("gvshow")); 149 | 150 | List models = table.findElements(By.tagName("td")); 151 | 152 | WebElement tables = driver.findElement(By.id("gvshow")); 153 | 154 | List modelName = tables.findElements(By.tagName("td")); 155 | 156 | for (WebElement modelNames : modelName) { 157 | 158 | System.out.println(modelNames.getText()); 159 | } 160 | } 161 | 162 | else { 163 | 164 | System.out.println("Submit Button isn't Clicked"); 165 | } 166 | 167 | driver.quit(); 168 | 169 | System.out.println("Run Successful"); 170 | 171 | } 172 | 173 | } 174 | 175 | -------------------------------------------------------------------------------- /Day8_PepperFry: -------------------------------------------------------------------------------- 1 | package twentyOneDayChallenge; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.concurrent.TimeUnit; 6 | 7 | import org.apache.commons.io.FileUtils; 8 | import org.openqa.selenium.Keys; 9 | import org.openqa.selenium.OutputType; 10 | import org.openqa.selenium.UnexpectedAlertBehaviour; 11 | import org.openqa.selenium.WebElement; 12 | import org.openqa.selenium.chrome.ChromeDriver; 13 | import org.openqa.selenium.chrome.ChromeOptions; 14 | import org.openqa.selenium.interactions.Actions; 15 | import org.openqa.selenium.remote.CapabilityType; 16 | import org.openqa.selenium.remote.DesiredCapabilities; 17 | 18 | 19 | 20 | public class Day8_Pepperfry { 21 | 22 | public static void main(String[] args) throws InterruptedException, IOException { 23 | 24 | 25 | System.setProperty("webdriver.chrome.driver", "./postman/chromedriver.exe"); 26 | 27 | ChromeOptions options = new ChromeOptions(); 28 | 29 | options.addArguments("--disable-notifications"); 30 | 31 | DesiredCapabilities capab = new DesiredCapabilities(); 32 | 33 | capab.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.DISMISS); 34 | 35 | options.merge(capab); 36 | 37 | ChromeDriver driver = new ChromeDriver(options); 38 | 39 | driver.get("https://www.pepperfry.com/"); 40 | 41 | driver.manage().window().maximize(); 42 | 43 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 44 | 45 | Actions action = new Actions(driver); 46 | 47 | action.moveToElement(driver.findElementByXPath("//a[text()='Furniture']")).build().perform(); 48 | Thread.sleep(2000); 49 | 50 | System.out.println("Mouse hovered to Furniture"); 51 | 52 | driver.findElementByXPath("//a[text()='Office Chairs']").click(); 53 | Thread.sleep(3000); 54 | 55 | System.out.println("selected Office Chairs"); 56 | 57 | action.moveToElement(driver.findElementByXPath("//img[@alt='Executive Chairs']")).click().build().perform(); 58 | Thread.sleep(2000); 59 | 60 | System.out.println("Clicked Executive Chairs"); 61 | 62 | action.moveToElement(driver.findElementByXPath("//img[@alt='High Back Executive Chairs']")).click().build().perform(); 63 | Thread.sleep(2000); 64 | 65 | System.out.println("Clciked High Back Executive Chairs"); 66 | 67 | driver.findElementByXPath("//div[@class='clip__filter-dimension-input-holder']//input[@type='number']").clear(); 68 | 69 | System.out.println("Existing value has been cleared"); 70 | 71 | driver.findElementByXPath("//div[@class='clip__filter-dimension-input-holder']//input[@type='number']").sendKeys("50", Keys.ENTER); 72 | Thread.sleep(2000); 73 | 74 | System.out.println("Entered the value 50"); 75 | 76 | driver.findElementByXPath("//a[text()='Poise Executive Chair in Black Colour']//ancestor::div[@class='clip-crd-10x11 pf-white padding-2x1']//a[@id='clip_wishlist_']").click(); 77 | System.out.println("Chair added to the whishlist"); 78 | 79 | action.moveToElement(driver.findElementByXPath("//a[text()='Homeware']")).build().perform(); 80 | Thread.sleep(2000); 81 | 82 | System.out.println("Mouse hovered to Homeware"); 83 | 84 | action.moveToElement(driver.findElementByXPath("//div[@class='hvr-col-listitem']//a[text()='Pressure Cookers']")).click().build().perform(); 85 | Thread.sleep(2000); 86 | 87 | System.out.println("Cliked Pressure Cookers"); 88 | 89 | driver.findElementByXPath("//li[@data-search='Prestige']//label[@for='brandsnamePrestige']").click(); 90 | Thread.sleep(3000); 91 | 92 | System.out.println("Checked Prestige Brand"); 93 | 94 | driver.findElementByXPath("//a[text()='Nakshatra Cute Metallic Red Aluminium Cooker 2 Ltr']//ancestor::div[@class='clip-crd-10x11 pf-white padding-2x1']//a[@id='clip_wishlist_']").click(); 95 | Thread.sleep(2000); 96 | 97 | System.out.println("Cooker added to the wishlist"); 98 | 99 | String text = driver.findElementByXPath("//div[@class='wishlist_bar']//span[@class='count_alert']").getText(); 100 | 101 | String replaceAll = text.replaceAll("\\D", ""); 102 | 103 | int wishListCount = Integer.parseInt(replaceAll); 104 | 105 | System.out.println("Whishlist count : "+ wishListCount ); 106 | 107 | driver.findElementByXPath("//a[@data-tooltip='Wishlist']").click(); 108 | Thread.sleep(2000); 109 | 110 | System.out.println("Clicked WishList"); 111 | 112 | driver.findElementByXPath("//a[text()='Nakshatra Cute Metallic Red Aluminium Cooker 2 Ltr By...']//ancestor::div[@class='item_card_wrapper']//a[@unbxdattr='AddToCart']").click(); 113 | Thread.sleep(2000); 114 | 115 | System.out.println("Added cooker to the cart"); 116 | 117 | driver.findElementByXPath("//div[@class='pin_block']//input").sendKeys("600128"); 118 | 119 | driver.findElementByClassName("check_available").click(); 120 | Thread.sleep(2000); 121 | 122 | System.out.println("Checked the availability"); 123 | 124 | driver.findElementByXPath("//a[text()='Proceed to pay securely ']").click(); 125 | Thread.sleep(3000); 126 | 127 | System.out.println("Clicked Proceed to pay"); 128 | 129 | driver.findElementByXPath("//a[text()='PLACE ORDER']").click(); 130 | Thread.sleep(2000); 131 | 132 | System.out.println("Order has been placed"); 133 | 134 | driver.findElementByXPath("//span[text()='ORDER SUMMARY']").click(); 135 | Thread.sleep(2000); 136 | 137 | File src = driver.findElementByXPath("//div[@class='slick-list draggable']//li").getScreenshotAs(OutputType.FILE); 138 | 139 | File desT = new File("./nakshatra/image.jpg"); 140 | 141 | FileUtils.copyFile(src, desT); 142 | 143 | System.out.println("Screenshot has been taken"); 144 | 145 | driver.close(); 146 | 147 | System.out.println("Run Successful"); 148 | 149 | 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /Day9_DemoCRM: -------------------------------------------------------------------------------- 1 | package twentyOneDayChallenge; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import org.openqa.selenium.By; 6 | import org.openqa.selenium.Keys; 7 | import org.openqa.selenium.WebElement; 8 | import org.openqa.selenium.chrome.ChromeDriver; 9 | import org.openqa.selenium.interactions.Actions; 10 | import org.openqa.selenium.support.ui.Select; 11 | 12 | public class Day9_demoCRM { 13 | 14 | public static void main(String[] args) throws InterruptedException { 15 | 16 | 17 | System.setProperty("webdriver.chrome.driver", "./postman/chromedriver.exe"); 18 | 19 | ChromeDriver driver = new ChromeDriver(); 20 | 21 | driver.get("https://demo.1crmcloud.com/"); 22 | 23 | driver.manage().window().maximize(); 24 | 25 | System.out.println("Browser Opened"); 26 | 27 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 28 | 29 | driver.findElement(By.id("login_user")).sendKeys("admin"); 30 | 31 | driver.findElementByXPath("//div[@class='input-field input-field-group input-block']//input[@name='user_password']").sendKeys("admin", Keys.TAB); 32 | 33 | WebElement selectTheme = driver.findElementById("login_theme"); 34 | 35 | Select dropDown = new Select(selectTheme); 36 | 37 | dropDown.selectByVisibleText("Claro Theme"); 38 | 39 | Thread.sleep(2000); 40 | 41 | driver.findElementByXPath("//button[@id='login_button']//span[text()='Login']").click(); 42 | Thread.sleep(3000); 43 | 44 | System.out.println("Logged in"); 45 | 46 | Actions action = new Actions(driver); 47 | 48 | action.moveToElement(driver.findElementByXPath("//a[@class='menubar-link']//div[text()='Sales & Marketing']")).click().build().perform(); 49 | 50 | System.out.println("Mouse clicked on Sales & Marketing"); 51 | 52 | driver.findElementByXPath("//div[text()='Create Contact']").click(); 53 | Thread.sleep(2000); 54 | 55 | System.out.println("Tapped on Account Creation Button"); 56 | Thread.sleep(4000); 57 | 58 | driver.findElementByXPath("//div[@id='DetailFormsalutation-input']").click(); 59 | Thread.sleep(2000); 60 | 61 | driver.findElementByXPath("//div[text()='Mr.']").click(); 62 | 63 | driver.findElementByXPath("//input[@class='input-text']").sendKeys("Karthick", Keys.TAB); 64 | 65 | driver.findElementByXPath("//input[@name='last_name']").sendKeys("vivek", Keys.TAB); 66 | 67 | System.out.println("Name is entered"); 68 | 69 | driver.findElementByXPath("//input[@type='email']").sendKeys("Karthickviv2k@hotmail.com", Keys.TAB); 70 | 71 | System.out.println("MAILID Entered"); 72 | 73 | driver.findElementByXPath("//input[@name='phone_work']").sendKeys("9600525900", Keys.TAB); 74 | 75 | System.out.println("Mobile number entered"); 76 | 77 | action.moveToElement(driver.findElementByXPath("(//div[@class='input-field input-field-group rbullet'])[2]")).click().build().perform(); 78 | 79 | driver.findElement(By.xpath("//div[text()='Public Relations']")).click(); 80 | Thread.sleep(3000); 81 | 82 | System.out.println("Selected Public Relation from Drop down"); 83 | 84 | driver.findElementById("DetailFormbusiness_role-input").click(); 85 | Thread.sleep(2000); 86 | 87 | driver.findElementByXPath("//div[text()='Sales']").click(); 88 | 89 | driver.findElementByXPath("//textarea[@name='primary_address_street']").sendKeys("No:74 Dubai Main Road, Ch-28", Keys.TAB); 90 | 91 | System.out.println("Entered Address"); 92 | 93 | driver.findElementByXPath("//input[@id='DetailFormprimary_address_city-input']").sendKeys("Chennai", Keys.TAB); 94 | 95 | System.out.println("Selected City"); 96 | 97 | driver.findElementByXPath("//input[@id='DetailFormprimary_address_state-input']").sendKeys("TamilNadu", Keys.TAB); 98 | 99 | System.out.println("Selected State"); 100 | 101 | driver.findElementByXPath("//input[@id='DetailFormprimary_address_country-input']").sendKeys("India", Keys.TAB); 102 | 103 | System.out.println("Selected Country"); 104 | 105 | driver.findElementByXPath("//input[@id='DetailFormprimary_address_postalcode-input']").sendKeys("600028"); 106 | Thread.sleep(3000); 107 | 108 | System.out.println("Entered PostalCode"); 109 | 110 | driver.findElementById("DetailForm_save2").click(); 111 | Thread.sleep(2000); 112 | 113 | System.out.println("***Saved the contact successfully***"); 114 | 115 | action.moveToElement(driver.findElementByXPath("//a[@class='menubar-link']//div")).build().perform(); 116 | Thread.sleep(2000); 117 | 118 | System.out.println("Hovered to Today's Activities"); 119 | 120 | driver.findElement(By.xpath("//div[text()='Meetings']")).click(); 121 | Thread.sleep(3000); 122 | 123 | driver.findElementByXPath("(//button[@class='input-button first'])[1]").click(); 124 | Thread.sleep(2000); 125 | 126 | driver.findElementById("DetailFormname-input").sendKeys("Project Status"); 127 | 128 | driver.findElementById("DetailFormstatus-input").click(); 129 | Thread.sleep(2000); 130 | 131 | driver.findElement(By.xpath("(//div[text()='Planned'])[2]")).click(); 132 | 133 | driver.findElementById("DetailFormdate_start-input").click(); 134 | Thread.sleep(2000); 135 | 136 | driver.findElementByXPath("(//div[@class='grid-row number-row'])[5]//div[text()='27']").click(); 137 | Thread.sleep(2000); 138 | 139 | driver.findElementByXPath("(//input[@class='input-text'])[4]").clear(); 140 | 141 | driver.findElementByXPath("(//input[@class='input-text'])[4]").sendKeys("15:00"); 142 | 143 | driver.findElementByXPath("//div[@class='active-icon uii-accept uii-lg uii']").click(); 144 | Thread.sleep(2000); 145 | 146 | System.out.println("Selected Meeting StartDate & Time "); 147 | 148 | driver.findElementById("DetailFormduration-time").clear(); 149 | 150 | driver.findElementById("DetailFormduration-time").sendKeys("1h 00m", Keys.TAB); 151 | 152 | System.out.println("Time Duration Added"); 153 | 154 | driver.findElementByXPath("//button[@name='addInvitee']").click(); 155 | Thread.sleep(3000); 156 | 157 | driver.findElementByXPath("//div[text()='Karthick vivek']").click(); 158 | Thread.sleep(2000); 159 | 160 | driver.findElementByXPath("//span[@id='DetailForm_save2-label']").click(); 161 | Thread.sleep(2000); 162 | System.out.println("**Meeting Saved Successfully***"); 163 | 164 | action.moveToElement(driver.findElementByXPath("//a[@class='menubar-link']//div[text()='Sales & Marketing']")).build().perform(); 165 | Thread.sleep(2000); 166 | 167 | driver.findElementByXPath("//div[text()='Contacts']").click(); 168 | Thread.sleep(2000); 169 | 170 | driver.findElementByXPath("//input[@id='filter_text']").sendKeys("Karthick vivek"); 171 | Thread.sleep(2000); 172 | 173 | driver.findElementByXPath("//div[@class='menu-option single']//div[text()='Mr. Karthick vivek']").click(); 174 | 175 | System.out.println("Search found for the name Karthick vivek"); 176 | 177 | String meetingText = driver.findElementByXPath("//a[text()='Project Status']").getText(); 178 | 179 | System.out.println(meetingText); 180 | 181 | 182 | if(meetingText.contains("Project Status")){ 183 | 184 | System.out.println("Yes, meeting is assigned"); 185 | 186 | } 187 | else { 188 | 189 | System.out.println("Sorry, meeting isn't assigned"); 190 | } 191 | 192 | driver.close(); 193 | 194 | } 195 | 196 | } 197 | 198 | -------------------------------------------------------------------------------- /Subtask_Automation: -------------------------------------------------------------------------------- 1 | package project_base_alexa; 2 | 3 | 4 | import java.util.Scanner; 5 | import java.util.concurrent.TimeUnit; 6 | import org.openqa.selenium.By; 7 | import org.openqa.selenium.Keys; 8 | import org.openqa.selenium.WebElement; 9 | import org.openqa.selenium.chrome.ChromeDriver; 10 | import org.openqa.selenium.interactions.Actions; 11 | 12 | public class Subtask_Jira_Automation { 13 | 14 | public static void main (String[]args) throws InterruptedException { 15 | 16 | System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver1.exe"); 17 | 18 | String Username = null, Password = null; 19 | int n; 20 | 21 | Scanner input = new Scanner(System.in); 22 | 23 | System.out.println("Enter the Username:"); 24 | Username = input.nextLine(); 25 | 26 | System.out.println("\nEnter your Password:"); 27 | Password = input.nextLine(); 28 | 29 | System.out.println("Enter the no.of Links:"); 30 | n = input.nextInt(); 31 | 32 | String[] link = new String[n]; 33 | 34 | for (int i = 0; i < n; i++) { 35 | System.out.println("Ther the link :"+i); 36 | link[i] = input.next(); 37 | } 38 | 39 | 40 | for (int i=0;i findElements = driver.findElementsByXPath("//u1[@class='results-base']"); 86 | 87 | int count = 0; 88 | 89 | for (WebElement brandName : findElements) { 90 | 91 | String manGO = brandName.getText(); 92 | 93 | if(manGO == "MANGO") { 94 | 95 | count = count + 1; 96 | } 97 | 98 | } 99 | if (count == findElements.size()) { 100 | System.out.println("All mango brands are displayed"); 101 | 102 | } 103 | 104 | builder.moveToElement(driver.findElementByXPath("//div[@class='sort-sortBy']")).build().perform(); 105 | 106 | builder.moveToElement(driver.findElementByXPath("//label[text()='Better Discount']")).click().build().perform(); 107 | 108 | Thread.sleep(3000); 109 | 110 | String rs = driver.findElement(By.xpath("(//span[@class='product-discountedPrice'])[1]")).getText(); 111 | 112 | String replacED = rs.replaceAll("\\D", ""); 113 | 114 | int parseInt4 = Integer.parseInt(replacED); 115 | 116 | System.out.println("The first better discount price is "+ parseInt4 ); 117 | 118 | WebElement mouseOver = driver.findElement(By.xpath("(//h4[@class='product-product'])[1]")); 119 | Thread.sleep(2000); 120 | 121 | builder.moveToElement(mouseOver).build().perform(); 122 | 123 | driver.findElement(By.xpath("(//span[text()='wishlist now'])[1]")).click(); 124 | 125 | String loginToMyntra = driver.findElement(By.className("login-title")).getText(); 126 | 127 | 128 | boolean title_Page = false; 129 | 130 | if (loginToMyntra.contains("Login")) { 131 | 132 | System.out.println("We are in login page"); 133 | } 134 | else 135 | { 136 | System.out.println("Wishlist did not get clicked:("); 137 | 138 | } 139 | driver.close(); 140 | 141 | System.out.println("Run successful"); 142 | } 143 | 144 | } 145 | 146 | -------------------------------------------------------------------------------- /day2_testleaf_Nykaa: -------------------------------------------------------------------------------- 1 | 2 | package twentyOneDayChallenge; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Set; 7 | import java.util.concurrent.TimeUnit; 8 | 9 | import org.openqa.selenium.By; 10 | import org.openqa.selenium.WebDriver; 11 | import org.openqa.selenium.WebElement; 12 | import org.openqa.selenium.chrome.ChromeDriver; 13 | import org.openqa.selenium.interactions.Actions; 14 | import org.openqa.selenium.support.ui.WebDriverWait; 15 | 16 | public class Day2_Nykaa_Selenium { 17 | 18 | public static void main(String[] args) throws InterruptedException { 19 | 20 | System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe"); 21 | 22 | ChromeDriver driver = new ChromeDriver(); 23 | 24 | driver.get("https://www.nykaa.com/"); 25 | 26 | driver.manage().window().maximize(); 27 | 28 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 29 | 30 | WebElement branD = driver.findElement(By.xpath("(//li[@class='menu-dropdown-icon']//a)[1]")); 31 | 32 | Actions action = new Actions(driver); 33 | 34 | action.moveToElement(branD).build().perform(); 35 | 36 | WebDriverWait wait = new WebDriverWait(driver, 30); 37 | 38 | WebElement populAR = driver.findElement(By.xpath("//div[@class='BrandsCategoryHeading']//a[1]")); 39 | 40 | action.moveToElement(populAR).build().perform(); 41 | 42 | driver.findElement(By.xpath("(//li[@class='brand-logo menu-links']//img)[5]")).click(); 43 | 44 | 45 | Set windowHandles = driver.getWindowHandles(); 46 | 47 | List windowList = new ArrayList(windowHandles); 48 | 49 | WebDriver window = driver.switchTo().window(windowList.get(1)); 50 | 51 | String title = window.getTitle(); 52 | 53 | if(title.contains("L'Oreal Paris")) { 54 | 55 | System.out.println("L'Oreal Paris is present in the title of the page"); 56 | } 57 | 58 | else { 59 | 60 | System.out.println("L'Oreal Paris isn't present in the title of the page"); 61 | } 62 | 63 | driver.findElement(By.xpath("//span[@class='pull-left']//span[1]")).click(); 64 | Thread.sleep(2000); 65 | 66 | driver.findElement(By.xpath("(//div[@class='control__indicator radio'])[4]")).click(); 67 | Thread.sleep(2000); 68 | 69 | 70 | String customerTopRated = driver.findElement(By.xpath("(//span[@class='pull-left']//span)[2]")).getText(); 71 | 72 | System.out.println("Filter is applied"); 73 | 74 | 75 | driver.findElement(By.xpath("(//div[@class='filter-sidebar__filter-title pull-left'])[1]")).click(); 76 | Thread.sleep(2000); 77 | 78 | driver.findElement(By.xpath("(//label[@for='chk_Shampoo_undefined']//div)[1]")).click(); 79 | Thread.sleep(2000); 80 | 81 | String shampooclose = driver.findElement(By.xpath("//li[text()='Shampoo']")).getText(); 82 | 83 | if(shampooclose.contains("Shampoo")) { 84 | 85 | System.out.println("Filter is applied for shampoo"); 86 | } 87 | else { 88 | 89 | System.out.println("Filter isn't applied"); 90 | } 91 | 92 | driver.findElement(By.xpath("(//img[@class='listing-img'])[4]")).click(); 93 | Thread.sleep(5000); 94 | 95 | Set windowHandles2 = driver.getWindowHandles(); 96 | 97 | List windowList2 = new ArrayList(windowHandles2); 98 | 99 | driver.switchTo().window(windowList2.get(2)); 100 | 101 | System.out.println("In the third tab"); 102 | 103 | driver.findElement(By.xpath("(//label[@class=' text-center']//span)[1]")).click(); 104 | 105 | String MRP = driver.findElement(By.xpath("(//span[text()='150'])[1]")).getText(); 106 | 107 | String pRrice = MRP.replaceAll("\\D", ""); 108 | 109 | System.out.println("MRP Of The Product is : "+ pRrice); 110 | 111 | driver.findElement(By.xpath("//div[@class='pull-left']//button[1]")).click(); 112 | 113 | driver.findElement(By.className("AddBagIcon")).click(); 114 | Thread.sleep(2000); 115 | 116 | driver.findElement(By.xpath("//span[text()='Proceed']")).click(); 117 | Thread.sleep(3000); 118 | 119 | driver.findElement(By.xpath("(//button[@type='button'])[2]")).click(); 120 | 121 | String warningMsg = driver.findElement(By.className("message")).getText(); 122 | 123 | System.out.println(warningMsg); 124 | 125 | driver.quit(); 126 | 127 | System.out.println("Run Successful"); 128 | } 129 | 130 | } 131 | 132 | 133 | -------------------------------------------------------------------------------- /day3_MakeMyTrip: -------------------------------------------------------------------------------- 1 | 2 | package twentyOneDayChallenge; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Set; 7 | import java.util.concurrent.TimeUnit; 8 | 9 | import org.openqa.selenium.By; 10 | import org.openqa.selenium.Keys; 11 | import org.openqa.selenium.WebElement; 12 | import org.openqa.selenium.chrome.ChromeDriver; 13 | import org.openqa.selenium.interactions.Actions; 14 | import org.openqa.selenium.support.ui.Select; 15 | import org.openqa.selenium.support.ui.WebDriverWait; 16 | 17 | public class Day3_MakeMyTrip { 18 | 19 | public static void main(String[] args) throws InterruptedException { 20 | 21 | 22 | System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe"); 23 | 24 | ChromeDriver driver = new ChromeDriver(); 25 | 26 | driver.get("https://www.makemytrip.com/"); 27 | 28 | driver.manage().window().maximize(); 29 | 30 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 31 | 32 | driver.findElement(By.xpath("//a[@href='https://www.makemytrip.com/hotels/']//span[1]")).click(); 33 | 34 | driver.findElementByXPath("//div[contains(@class,'hsw_inputBox selectHtlCity')]").click(); 35 | 36 | System.out.println("Moved to Hotels option"); 37 | 38 | WebDriverWait wait = new WebDriverWait(driver, 20); 39 | 40 | Actions action = new Actions(driver); 41 | 42 | WebElement seaRCH = driver.findElement(By.xpath("//input[contains(@class,'react-autosuggest__input react-autosuggest__input--open')]")); 43 | 44 | action.moveToElement(seaRCH).click().build().perform(); 45 | 46 | driver.findElement(By.xpath("//input[contains(@class,'react-autosuggest__input react-autosuggest__input--open')]")).sendKeys("Goa"); 47 | 48 | driver.findElementByXPath("//li[@id='react-autowhatever-1-section-0-item-0']//p[text()='Goa, India']").click(); 49 | 50 | Thread.sleep(2000); 51 | 52 | System.out.println("Goa has been selected"); 53 | 54 | driver.findElementById("checkin").click(); 55 | 56 | Thread.sleep(2000); 57 | 58 | WebElement mAY15 = driver.findElementByXPath("//div[@class='DayPicker-Months']//div[@class='DayPicker-Month'][2]//div[@class='DayPicker-Body']//div/div[text()='15']"); 59 | 60 | mAY15.click(); 61 | 62 | driver.findElementByXPath("//div[text()='May']//ancestor::div[@class='DayPicker-Month']//div[@class='DayPicker-Day' and text()='19']").click(); 63 | 64 | driver.findElement(By.xpath("//span[text()=' Room ']")).click(); 65 | 66 | driver.findElement(By.xpath("//li[@data-cy='adults-2']")).click(); 67 | 68 | driver.findElement(By.xpath("//li[@data-cy='children-1']")).click(); 69 | 70 | WebElement cHILDAGE = driver.findElement(By.className("ageSelectBox")); 71 | 72 | Select dropDown = new Select(cHILDAGE); 73 | 74 | dropDown.selectByVisibleText("12"); 75 | 76 | driver.findElement(By.xpath("(//button[@type='button'])[2]")).click(); 77 | Thread.sleep(2000); 78 | 79 | driver.findElement(By.id("hsw_search_button")).click(); 80 | Thread.sleep(3000); 81 | 82 | System.out.println("Tapped on Search"); 83 | 84 | action.moveToElement(driver.findElementById("seoH1DontRemove")).click().build().perform(); 85 | 86 | driver.findElement(By.xpath("//label[text()='Baga']")).click(); 87 | Thread.sleep(4000); 88 | 89 | driver.findElement(By.xpath("//label[text()='5 Star']")).click(); 90 | Thread.sleep(2000); 91 | 92 | driver.findElement(By.xpath("(//img[@alt='hotelImg'])[2]")).click(); 93 | 94 | System.out.println("Clicked the second hotel"); 95 | 96 | Set windowHandles = driver.getWindowHandles(); 97 | 98 | List newWindow = new ArrayList(windowHandles); 99 | 100 | driver.switchTo().window(newWindow.get(1)); 101 | 102 | System.out.println("New window opened"); 103 | 104 | String hotelName = driver.findElement(By.id("detpg_hotel_name")).getText(); 105 | 106 | System.out.println(hotelName); 107 | 108 | driver.findElement(By.xpath("(//span[contains(@class,'latoBold font10')])[2]")).click(); 109 | Thread.sleep(2000); 110 | 111 | driver.findElement(By.xpath("(//td[@class='textRight']//span)[1]")).click(); 112 | 113 | driver.findElement(By.className("close")).click(); 114 | 115 | driver.findElement(By.id("detpg_headerright_book_now")).click(); 116 | 117 | System.out.println("Selected Book this now"); 118 | Thread.sleep(3000); 119 | 120 | // driver.findElement(By.xpath("(//div[@class='_Modal modalCont']//span)[1]")).click(); 121 | 122 | String iNR = driver.findElement(By.id("revpg_total_payable_amt")).getText(); 123 | 124 | String totalAmt = iNR.replaceAll("\\D", ""); 125 | 126 | int parseInt = Integer.parseInt(totalAmt); 127 | 128 | System.out.println(parseInt); 129 | 130 | driver.quit(); 131 | 132 | System.out.println("Run successful"); 133 | 134 | 135 | } 136 | 137 | } 138 | -------------------------------------------------------------------------------- /day4_hpStore.in: -------------------------------------------------------------------------------- 1 | package twentyOneDayChallenge; 2 | 3 | import java.util.NoSuchElementException; 4 | import java.util.concurrent.TimeUnit; 5 | 6 | import org.openqa.selenium.By; 7 | import org.openqa.selenium.WebElement; 8 | import org.openqa.selenium.chrome.ChromeDriver; 9 | import org.openqa.selenium.interactions.Actions; 10 | import org.openqa.selenium.support.ui.ExpectedConditions; 11 | import org.openqa.selenium.support.ui.Select; 12 | import org.openqa.selenium.support.ui.WebDriverWait; 13 | 14 | public class Day4_hpStore { 15 | 16 | public static void main (String [] args) throws InterruptedException { 17 | 18 | 19 | System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe"); 20 | 21 | ChromeDriver driver = new ChromeDriver(); 22 | 23 | driver.get("https://store.hp.com/in-en/"); 24 | 25 | System.out.println("In the hp_Store webpage"); 26 | 27 | driver.manage().window().maximize(); 28 | 29 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 30 | 31 | WebElement laptoPS = driver.findElementByXPath("//a[contains(@class,'level-top ui-corner-all has-dropdown-menu')]//span[text()='Laptops']"); 32 | 33 | Actions action = new Actions(driver); 34 | 35 | action.moveToElement(laptoPS).build().perform(); 36 | Thread.sleep(2000); 37 | 38 | driver.findElementByXPath("//a[contains(@class,'ui-corner-all')]//span[text()='Pavilion']").click(); 39 | 40 | System.out.println("Clicked Pavilion"); 41 | 42 | WebDriverWait wait = new WebDriverWait(driver, 20); 43 | 44 | wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@aria-label='Accept Cookies']"))); 45 | 46 | driver.findElementByXPath("//button[@aria-label='Accept Cookies']").click(); 47 | 48 | System.out.println("Accept Cookies button clicked"); 49 | Thread.sleep(3000); 50 | 51 | driver.findElementByXPath("(//span[text()='Processor'])[2]").click(); 52 | driver.findElementByXPath("//span[text()='Intel Core i7']").click(); 53 | 54 | System.out.println("Checked Processor"); 55 | Thread.sleep(4000); 56 | 57 | 58 | driver.findElementByXPath("//span[contains(text(),'More than 1 TB')]").click(); 59 | Thread.sleep(3000); 60 | 61 | System.out.println("Checked Hard Driver Capacity"); 62 | 63 | WebElement sortBy = driver.findElement(By.xpath("(//select[@id='sorter'])[1]")); 64 | 65 | Select dropDown = new Select(sortBy); 66 | 67 | dropDown.selectByValue("price_asc"); 68 | Thread.sleep(2000); 69 | 70 | System.out.println("Filter have been applied"); 71 | 72 | System.out.println(driver.findElement(By.xpath("(//a[@class='product-item-link'])[1]")).getText()); 73 | 74 | String str = driver.findElement(By.xpath("(//span[@class='price'])[2]")).getText(); 75 | 76 | 77 | String priceOFLap = str.replaceAll("\\D", ""); 78 | 79 | int parseInt = Integer.parseInt(priceOFLap); 80 | 81 | System.out.println("Price of the laptop : "+parseInt); 82 | 83 | driver.findElement(By.xpath("(//span[text()='Add To Cart'])[1]")).click(); 84 | Thread.sleep(3000); 85 | 86 | System.out.println("Added to the cart"); 87 | 88 | driver.findElement(By.xpath("//a[@class='action showcart']")).click(); 89 | 90 | driver.findElement(By.xpath("//span[text()='View and edit cart']")).click(); 91 | Thread.sleep(3000); 92 | 93 | System.out.println("Clicked on View and Edit button"); 94 | 95 | driver.findElement(By.name("pincode")).sendKeys("600021"); 96 | 97 | System.out.println("Passed the pincode value"); 98 | 99 | driver.findElement(By.xpath("(//button[@type='button'])[4]")).click(); 100 | 101 | System.out.println("Checked"); 102 | Thread.sleep(3000); 103 | 104 | String str2 = driver.findElement(By.xpath("//td[@data-th='Order Total']//span[1]")).getText(); 105 | 106 | String veriFY = str2.replaceAll("\\D", ""); 107 | 108 | int veriFication = Integer.parseInt(veriFY); 109 | 110 | if(veriFication == parseInt) { 111 | 112 | System.out.println("Product price matched"); 113 | 114 | try { 115 | driver.findElementByXPath("//div[@class='inside_closeButton fonticon icon-hclose']").click(); 116 | } 117 | catch(NoSuchElementException e) 118 | { 119 | 120 | } 121 | 122 | //driver.findElementByXPath("//div[@class='inside_closeButton fonticon icon-hclose']").click(); 123 | 124 | driver.findElement(By.xpath("(//span[text()='Proceed to Checkout'])[1]")).click(); 125 | Thread.sleep(4000); 126 | 127 | driver.findElement(By.xpath("//div[@class='place-order-primary']//button[1]")).click(); 128 | 129 | System.out.println("Selected Place order button"); 130 | 131 | System.out.println("Warning message : " +driver.findElement(By.xpath("//span[text()='Please specify a payment method.']")).getText()); 132 | 133 | } 134 | 135 | else { 136 | 137 | System.out.println("No price match found"); 138 | } 139 | 140 | 141 | driver.quit(); 142 | 143 | System.out.println("Run Successfull" ); 144 | 145 | } 146 | 147 | } 148 | 149 | --------------------------------------------------------------------------------