└── A12-selenium-superstar
├── .classpath
├── .gitignore
├── .project
├── .settings
├── org.eclipse.jdt.core.prefs
└── org.eclipse.m2e.core.prefs
├── errorShots
├── webelement.png
└── webpage.png
├── pom.xml
├── screenshot.png
└── src
└── test
├── java
├── html
│ ├── A12-basic.html
│ ├── dd.html
│ ├── expression.html
│ ├── family.html
│ └── fileupload.html
├── initial_days
│ └── FirstLine.java
├── manage_methods
│ └── Window_Methods.java
├── methods_of_webelement
│ └── Instagram.java
├── search_context_methods
│ ├── DirectLocator.java
│ └── Expressions.java
├── working_with_actions
│ ├── FaceBook.java
│ ├── FacebookForKeyboard.java
│ ├── FacebookForKeyboardAssignment.java
│ ├── GlobalsQA.java
│ ├── Slider.java
│ ├── YonoSbi.java
│ └── Zomato.java
├── working_with_dropdown
│ ├── Bolly.java
│ ├── FaceBook.java
│ └── SingleSelectDD.java
├── working_with_iframes
│ ├── ServerOpen.java
│ └── Slider.java
├── working_with_javascriptexecutor
│ ├── Facebook.java
│ └── Zomato.java
├── working_with_popups
│ ├── Authentication.java
│ ├── FileUploadHandle.java
│ ├── FileUploadHandleRobot.java
│ ├── FileUploadIgnore.java
│ ├── JSPopup.java
│ ├── Jenkins.pdf
│ ├── Jenkins.png
│ └── Notification.java
├── working_with_screenshots
│ └── FaceBook.java
├── working_with_synchronization
│ ├── CloseQuit.java
│ ├── Heroku.java
│ ├── Shoppersstack.java
│ ├── ShoppersstackFluentWait.java
│ └── TheInternet.java
└── working_with_window_handling
│ ├── FaceBook.java
│ └── Shoppersstack.java
└── resources
├── TestNG.pdf
├── uploadFile.au3
└── uploadFile.exe
/A12-selenium-superstar/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | A12-selenium-superstar
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
3 | org.eclipse.jdt.core.compiler.compliance=1.8
4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
7 | org.eclipse.jdt.core.compiler.release=disabled
8 | org.eclipse.jdt.core.compiler.source=1.8
9 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/errorShots/webelement.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AutomationWithPiyushhh/A12-selenium-superstars/01a497de31abf03ea50daf4b1740e7e9fbad2733/A12-selenium-superstar/errorShots/webelement.png
--------------------------------------------------------------------------------
/A12-selenium-superstar/errorShots/webpage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AutomationWithPiyushhh/A12-selenium-superstars/01a497de31abf03ea50daf4b1740e7e9fbad2733/A12-selenium-superstar/errorShots/webpage.png
--------------------------------------------------------------------------------
/A12-selenium-superstar/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 | org.qspiders.automationwithpiyush
7 | A12-selenium-superstar
8 | 0.0.1
9 |
10 |
11 |
13 |
14 | org.seleniumhq.selenium
15 | selenium-java
16 | 4.34.0
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AutomationWithPiyushhh/A12-selenium-superstars/01a497de31abf03ea50daf4b1740e7e9fbad2733/A12-selenium-superstar/screenshot.png
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/html/A12-basic.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | A12-Selenium-Superstars
4 |
5 |
6 | A12 Registration Form
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | Terms & conditions
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/html/dd.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | The select multiple attribute
6 |
7 | The multiple attribute specifies that multiple options can be selected at once:
8 |
9 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/html/expression.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | A12-Selenium-Superstars
4 |
5 |
6 | A12 Registration Form
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | Terms & conditions
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/html/family.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Mahabharat XPath Playground
4 |
31 |
32 |
33 |
34 | Kappor's XPath Playground
35 |
36 |
37 | Prithviraj
38 |
39 | Raj
40 |
41 | Randhir
42 |
Karishma
43 |
44 | Kareena
45 |
Temur
46 |
47 |
48 |
49 | Rishi
50 |
Ranbir
51 |
52 |
53 |
Shammi
54 |
Shashi
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/html/fileupload.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | File upload popup
5 |
6 |
7 |
8 | Enter your name and upload your resume :
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/initial_days/FirstLine.java:
--------------------------------------------------------------------------------
1 | package initial_days;
2 |
3 | import org.openqa.selenium.WebDriver;
4 | import org.openqa.selenium.chrome.ChromeDriver;
5 | import org.openqa.selenium.edge.EdgeDriver;
6 | import org.openqa.selenium.firefox.FirefoxDriver;
7 |
8 | public class FirstLine {
9 | public static void main(String[] args) {
10 |
11 | WebDriver driver = new ChromeDriver();
12 | // driver = new EdgeDriver();
13 | // driver = new FirefoxDriver();
14 |
15 | driver.get("https://www.swiggy.com/");
16 |
17 | String title = driver.getTitle();
18 | System.out.println(title);
19 |
20 | String currentUrl = driver.getCurrentUrl();
21 | System.out.println(currentUrl);
22 |
23 | System.out.println(driver.getPageSource());
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/manage_methods/Window_Methods.java:
--------------------------------------------------------------------------------
1 | package manage_methods;
2 |
3 | import org.openqa.selenium.Dimension;
4 | import org.openqa.selenium.Point;
5 | import org.openqa.selenium.WebDriver;
6 | import org.openqa.selenium.WebDriver.Window;
7 | import org.openqa.selenium.chrome.ChromeDriver;
8 |
9 | public class Window_Methods {
10 | public static void main(String[] args) throws InterruptedException {
11 | WebDriver driver = new ChromeDriver();
12 |
13 | driver.get("https://www.facebook.com/");
14 |
15 | Window win = driver.manage().window();
16 |
17 | // win.maximize();
18 | //
19 | // Thread.sleep(1000);
20 | //
21 | // win.minimize();
22 | //
23 | // Thread.sleep(1000);
24 | //
25 | // win.fullscreen();
26 |
27 |
28 | Dimension dim = win.getSize();
29 | System.out.println(dim);
30 |
31 | int h = dim.getHeight();
32 | int w = dim.getWidth();
33 | //
34 | // System.out.println("height is : " + h);
35 | // System.out.println("width is : " + w);
36 |
37 | // Dimension dim2 = new Dimension(1350, 800);
38 | // win.setSize(dim2);
39 | //
40 | // Thread.sleep(2000);
41 | // win.setSize(dim);
42 |
43 |
44 | Point pt = win.getPosition();
45 | System.out.println(pt);
46 |
47 | driver.manage().window().maximize();
48 | System.out.println("The size of window in width and lenght : "+win.getSize());
49 |
50 | pt = win.getPosition();
51 |
52 | System.out.println(pt);
53 |
54 | Point pt2 = new Point(w/2, h/2);
55 |
56 | win.setPosition(pt2);
57 |
58 | Thread.sleep(7000);
59 | driver.quit();
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/methods_of_webelement/Instagram.java:
--------------------------------------------------------------------------------
1 | package methods_of_webelement;
2 |
3 | import org.openqa.selenium.By;
4 | import org.openqa.selenium.WebDriver;
5 | import org.openqa.selenium.WebElement;
6 | import org.openqa.selenium.chrome.ChromeDriver;
7 |
8 | public class Instagram {
9 | public static void main(String[] args) throws InterruptedException {
10 | WebDriver driver = new ChromeDriver();
11 | driver.manage().window().maximize();
12 |
13 |
14 | driver.get("https://www.facebook.com/");
15 |
16 | WebElement un = driver.findElement(By.id("email"));
17 | WebElement login = driver.findElement(By.name("login"));
18 |
19 | un.sendKeys("1234567");
20 | Thread.sleep(1000);
21 | un.clear();
22 |
23 |
24 | if (login.isDisplayed() && login.isEnabled()) {
25 | // login.click();
26 | }
27 |
28 | driver.findElement(By.linkText("Create new account")).click();
29 |
30 | WebElement maleRadio = driver.findElement(By.xpath("//label[text()='Male']/input"));
31 | if (maleRadio.isDisplayed() && maleRadio.isEnabled()) {
32 | System.out.println(maleRadio.isSelected());
33 | maleRadio.click();
34 | System.out.println(maleRadio.isSelected());
35 | }
36 |
37 |
38 | // System.out.println(maleRadio.getSize());
39 | // System.out.println(maleRadio.getLocation());
40 |
41 | System.out.println(maleRadio.getRect().getDimension());
42 | System.out.println(maleRadio.getRect().getPoint());
43 | System.out.println(maleRadio.getRect().getHeight());
44 | System.out.println(maleRadio.getRect().getWidth());
45 | System.out.println(maleRadio.getRect().getX());
46 | System.out.println(maleRadio.getRect().getY());
47 |
48 | // login.submit();
49 |
50 |
51 |
52 |
53 | // System.out.println(un.getAttribute("data-testid"));
54 | // String fontSize = un.getCssValue("font-size");
55 | // System.out.println(fontSize);
56 |
57 |
58 | Thread.sleep(2000);
59 | driver.quit();
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/search_context_methods/DirectLocator.java:
--------------------------------------------------------------------------------
1 | package search_context_methods;
2 |
3 | import java.util.List;
4 |
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.WebElement;
8 | import org.openqa.selenium.chrome.ChromeDriver;
9 |
10 | public class DirectLocator {
11 | public static void main(String[] args) throws InterruptedException {
12 |
13 | WebDriver driver = new ChromeDriver();
14 |
15 | driver.get("https://www.amazon.in/");
16 |
17 | // driver.findElement(By.linkText("Forgot password?")).click();
18 |
19 | // driver.findElement(By.className("_8esh")).click();
20 |
21 | List links = driver.findElements(By.tagName("a"));
22 | System.out.println(links.size());
23 |
24 | Thread.sleep(3000);
25 |
26 | driver.quit();
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/search_context_methods/Expressions.java:
--------------------------------------------------------------------------------
1 | package search_context_methods;
2 |
3 | import org.openqa.selenium.By;
4 | import org.openqa.selenium.WebDriver;
5 | import org.openqa.selenium.chrome.ChromeDriver;
6 |
7 | public class Expressions {
8 | public static void main(String[] args) throws InterruptedException {
9 | WebDriver driver = new ChromeDriver();
10 | driver.manage().window().maximize();
11 |
12 | driver.get("https://www.facebook.com/");
13 |
14 | Thread.sleep(2000);
15 | driver.findElement(By.cssSelector("input[type='text']")).sendKeys("1234567890");
16 | Thread.sleep(2000);
17 | driver.findElement(By.xpath("//input[@data-testid='royal-pass']")).sendKeys("123456789");
18 |
19 | driver.findElement(By.xpath("//button[text()='Log in']")).click();
20 |
21 |
22 |
23 | Thread.sleep(10000);
24 | driver.quit();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_actions/FaceBook.java:
--------------------------------------------------------------------------------
1 | package working_with_actions;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.WebElement;
8 | import org.openqa.selenium.chrome.ChromeDriver;
9 | import org.openqa.selenium.interactions.Actions;
10 |
11 | public class FaceBook {
12 | public static void main(String[] args) throws InterruptedException {
13 | WebDriver driver = new ChromeDriver();
14 | driver.manage().window().maximize();
15 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
16 |
17 | driver.get("https://www.facebook.com/");
18 |
19 | WebElement link = driver.findElement(By.linkText("Create a Page"));
20 |
21 | Thread.sleep(5000);
22 |
23 | Actions act = new Actions(driver);
24 | // act.moveToElement(link).build().perform();
25 |
26 | act.contextClick(link).build().perform();
27 |
28 | Thread.sleep(10000);
29 | driver.quit();
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_actions/FacebookForKeyboard.java:
--------------------------------------------------------------------------------
1 | package working_with_actions;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.Keys;
7 | import org.openqa.selenium.WebDriver;
8 | import org.openqa.selenium.WebElement;
9 | import org.openqa.selenium.chrome.ChromeDriver;
10 | import org.openqa.selenium.interactions.Actions;
11 |
12 | public class FacebookForKeyboard {
13 | public static void main(String[] args) {
14 | WebDriver driver = new ChromeDriver();
15 | driver.manage().window().maximize();
16 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
17 |
18 | driver.get("https://www.facebook.com/");
19 |
20 | Actions act = new Actions(driver);
21 | act.sendKeys("admin").build().perform();
22 |
23 | // WebElement pwd = driver.findElement(By.id("pass"));
24 | // act.sendKeys(pwd, "admin@123456").build().perform();
25 |
26 | act.keyDown(Keys.TAB).perform();
27 | act.keyUp(Keys.TAB).perform();
28 |
29 | act.sendKeys("admin@123456").build().perform();
30 |
31 | // One line for all the task
32 | act.sendKeys("admin" + Keys.TAB + "admin@123456").build().perform();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_actions/FacebookForKeyboardAssignment.java:
--------------------------------------------------------------------------------
1 | package working_with_actions;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.Keys;
7 | import org.openqa.selenium.WebDriver;
8 | import org.openqa.selenium.WebElement;
9 | import org.openqa.selenium.chrome.ChromeDriver;
10 | import org.openqa.selenium.interactions.Actions;
11 |
12 | public class FacebookForKeyboardAssignment {
13 | public static void main(String[] args) {
14 | WebDriver driver = new ChromeDriver();
15 | driver.manage().window().maximize();
16 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
17 |
18 | driver.get("https://www.facebook.com/");
19 |
20 | Actions act = new Actions(driver);
21 | act.sendKeys("admin").build().perform();
22 |
23 | // act.keyDown(Keys.CONTROL).build().perform();
24 | // act.sendKeys("a").build().perform();
25 | // act.keyUp(Keys.CONTROL).build().perform();
26 |
27 | new Actions(driver).keyDown(Keys.CONTROL).sendKeys("a").keyUp(Keys.CONTROL).build().perform();
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_actions/GlobalsQA.java:
--------------------------------------------------------------------------------
1 | package working_with_actions;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.WebElement;
8 | import org.openqa.selenium.chrome.ChromeDriver;
9 | import org.openqa.selenium.interactions.Actions;
10 |
11 | public class GlobalsQA {
12 | public static void main(String[] args) throws InterruptedException {
13 | WebDriver driver = new ChromeDriver();
14 | driver.manage().window().maximize();
15 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
16 |
17 | driver.get("https://www.globalsqa.com/demo-site/draganddrop/");
18 |
19 | // driver.switchTo().frame(0);
20 | driver.switchTo().frame(3);
21 |
22 | WebElement src1 = driver.findElement(By.cssSelector("img[alt='The peaks of High Tatras']"));
23 | WebElement src2 = driver.findElement(By.cssSelector("img[alt='The chalet at the Green mountain lake']"));
24 | WebElement src3 = driver.findElement(By.cssSelector("img[alt='Planning the ascent']"));
25 | WebElement src4 = driver.findElement(By.cssSelector("img[alt='On top of Kozi kopka']"));
26 | WebElement destination = driver.findElement(By.id("trash"));
27 |
28 | int x1 = src1.getLocation().getX();
29 | int y1 = src1.getLocation().getY();
30 |
31 | int x2 = destination.getLocation().getX();
32 | int y2 = destination.getLocation().getY();
33 |
34 | System.out.println(src1.getLocation());
35 | System.out.println(destination.getLocation());
36 |
37 | System.out.println(x2-x1);
38 | System.out.println(y2-y1);
39 | Actions act = new Actions(driver);
40 |
41 | // dragAndDrop(src,dest)
42 | // act.dragAndDrop(src1, destination).build().perform();
43 | // Thread.sleep(1000);
44 | // act.dragAndDrop(src2, destination).build().perform();
45 | // Thread.sleep(1000);
46 | // act.dragAndDrop(src3, destination).build().perform();
47 | // Thread.sleep(1000);
48 | // act.dragAndDrop(src4, destination).build().perform();
49 |
50 | // dragAndDrop(src,dest)
51 | act.dragAndDropBy(src1, 442,31).build().perform();
52 | Thread.sleep(1000);
53 | act.dragAndDropBy(src2, 442,31).build().perform();
54 | Thread.sleep(1000);
55 | act.dragAndDropBy(src3, 442,31).build().perform();
56 | Thread.sleep(1000);
57 | act.dragAndDropBy(src4, 442,31).build().perform();
58 |
59 | Thread.sleep(5000);
60 | driver.quit();
61 |
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_actions/Slider.java:
--------------------------------------------------------------------------------
1 | package working_with_actions;
2 |
3 | import org.openqa.selenium.By;
4 | import org.openqa.selenium.WebDriver;
5 | import org.openqa.selenium.WebElement;
6 | import org.openqa.selenium.chrome.ChromeDriver;
7 | import org.openqa.selenium.interactions.Actions;
8 |
9 | public class Slider {
10 | public static void main(String[] args) throws InterruptedException {
11 | WebDriver driver = new ChromeDriver();
12 |
13 | driver.get("https://jqueryui.com/slider/");
14 |
15 | driver.switchTo().frame(0);
16 |
17 | WebElement slider = driver.findElement(By.id("slider"));
18 |
19 | Actions act = new Actions(driver);
20 | // act.moveToElement(slider).click().moveByOffset(50, 0).build().perform();
21 | // act.moveToElement(slider, 50, 0).click().build().perform();
22 | act.contextClick().build().perform();
23 |
24 | Thread.sleep(5000);
25 | driver.quit();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_actions/YonoSbi.java:
--------------------------------------------------------------------------------
1 | package working_with_actions;
2 |
3 | import org.openqa.selenium.By;
4 | import org.openqa.selenium.WebDriver;
5 | import org.openqa.selenium.WebElement;
6 | import org.openqa.selenium.chrome.ChromeDriver;
7 | import org.openqa.selenium.interactions.Actions;
8 |
9 | public class YonoSbi {
10 | public static void main(String[] args) throws InterruptedException {
11 | WebDriver driver = new ChromeDriver();
12 |
13 | driver.get("https://yonobusiness.sbi/yonobusinesslogin");
14 |
15 | driver.findElement(By.id("password")).sendKeys("123456");
16 |
17 | WebElement eyeIcon = driver.findElement(By.cssSelector("img[src=\"assets/img/Revamp/icon_eye_close.svg\"]"));
18 |
19 | Actions act = new Actions(driver);
20 | act.clickAndHold(eyeIcon).build().perform();
21 |
22 | Thread.sleep(3000);
23 | act.release().build().perform();
24 |
25 | Thread.sleep(10000);
26 | driver.quit();
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_actions/Zomato.java:
--------------------------------------------------------------------------------
1 | package working_with_actions;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.WebElement;
8 | import org.openqa.selenium.chrome.ChromeDriver;
9 | import org.openqa.selenium.interactions.Actions;
10 |
11 | public class Zomato {
12 | public static void main(String[] args) throws InterruptedException {
13 | WebDriver driver = new ChromeDriver();
14 | driver.manage().window().maximize();
15 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
16 |
17 | driver.get("https://www.facebook.com/");
18 |
19 | WebElement forgotPwd = driver.findElement(By.xpath("//a[contains(@id,\"u_0_6_\")]"));
20 |
21 | Thread.sleep(5000);
22 |
23 | Actions act = new Actions(driver);
24 | act.moveToElement(forgotPwd).build().perform();
25 |
26 | Thread.sleep(5000);
27 | driver.quit();
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_dropdown/Bolly.java:
--------------------------------------------------------------------------------
1 | package working_with_dropdown;
2 |
3 | import java.time.Duration;
4 | import java.util.List;
5 |
6 | import org.openqa.selenium.By;
7 | import org.openqa.selenium.WebDriver;
8 | import org.openqa.selenium.WebElement;
9 | import org.openqa.selenium.chrome.ChromeDriver;
10 | import org.openqa.selenium.support.ui.Select;
11 |
12 | public class Bolly {
13 | public static void main(String[] args) throws InterruptedException {
14 | WebDriver driver = new ChromeDriver();
15 | driver.manage().window().maximize();
16 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
17 |
18 | driver.get("C:\\Users\\User\\git\\A12-Basic-selenium\\A12-selenium-superstar\\src\\test\\java\\html\\dd.html");
19 |
20 | WebElement characterDD = driver.findElement(By.id("kalakar"));
21 | Select selChar = new Select(characterDD);
22 |
23 |
24 | boolean status = selChar.isMultiple();
25 | if (status) {
26 | System.out.println("given dd is multiselect");
27 | }else {
28 | System.out.println("given dd is single select");
29 | }
30 |
31 | // selChar.selectByIndex(5);
32 | // selChar.selectByIndex(11);
33 | List chars = selChar.getOptions();
34 | System.out.println(chars.size());
35 |
36 | for (int i = 5; i < chars.size(); i++) {
37 | selChar.selectByIndex(i);
38 | }
39 |
40 | WebElement firstSelected = selChar.getFirstSelectedOption();
41 | System.out.println(firstSelected.getText());
42 |
43 | // selChar.deselectByIndex(5);
44 | // selChar.deselectByIndex(11);
45 |
46 | selChar.deselectAll();
47 |
48 | List selected = selChar.getAllSelectedOptions();
49 | System.out.println(selected.size());
50 |
51 | for (WebElement i : selected) {
52 | System.out.println(i.getText());
53 | }
54 |
55 | Thread.sleep(3000);
56 | driver.quit();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_dropdown/FaceBook.java:
--------------------------------------------------------------------------------
1 | package working_with_dropdown;
2 |
3 | import java.time.Duration;
4 | import java.util.List;
5 |
6 | import org.openqa.selenium.By;
7 | import org.openqa.selenium.WebDriver;
8 | import org.openqa.selenium.WebElement;
9 | import org.openqa.selenium.chrome.ChromeDriver;
10 | import org.openqa.selenium.support.ui.Select;
11 |
12 | public class FaceBook {
13 | public static void main(String[] args) throws InterruptedException {
14 | WebDriver driver = new ChromeDriver();
15 | driver.manage().window().maximize();
16 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
17 |
18 | driver.get("https://www.facebook.com/r.php?entry_point=login");
19 |
20 | WebElement dayDD = driver.findElement(By.id("day"));
21 | WebElement monthDD = driver.findElement(By.id("month"));
22 | WebElement yearDD = driver.findElement(By.id("year"));
23 |
24 | Select selDay = new Select(dayDD);
25 | Select selMon = new Select(monthDD);
26 | Select selYear = new Select(yearDD);
27 |
28 | selDay.selectByIndex(0);
29 | selMon.selectByValue("2");
30 | selYear.selectByVisibleText("1947");
31 |
32 | List years = selYear.getOptions();
33 | for (WebElement i : years) {
34 | System.out.println(i.getText());
35 | }
36 |
37 |
38 | Thread.sleep(3000);
39 | driver.quit();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_dropdown/SingleSelectDD.java:
--------------------------------------------------------------------------------
1 | package working_with_dropdown;
2 |
3 | import java.util.List;
4 |
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.WebElement;
8 | import org.openqa.selenium.chrome.ChromeDriver;
9 | import org.openqa.selenium.support.ui.Select;
10 |
11 | public class SingleSelectDD {
12 | public static void main(String[] args) throws InterruptedException {
13 | WebDriver driver = new ChromeDriver();
14 |
15 | driver.get("C:\\Users\\User\\git\\A12-Basic-selenium\\A12-selenium-superstar\\src\\test\\java\\html\\dd.html");
16 |
17 | WebElement studentsDD = driver.findElement(By.id("student"));
18 |
19 | Select selStud = new Select(studentsDD);
20 |
21 | List students = selStud.getOptions();
22 | for (WebElement i : students) {
23 | System.out.println(i.getText() + " value : " + i.getAttribute("value"));
24 | }
25 |
26 | // selStud.selectByIndex(3);
27 | // Thread.sleep(1000);
28 | // selStud.selectByValue("shekhar");
29 | // Thread.sleep(1000);
30 | // selStud.selectByVisibleText("Prince");
31 | // Thread.sleep(1000);
32 | // selStud.selectByIndex(4);
33 | // Thread.sleep(1000);
34 |
35 |
36 | Thread.sleep(2000);
37 | driver.quit();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_iframes/ServerOpen.java:
--------------------------------------------------------------------------------
1 | package working_with_iframes;
2 |
3 | import org.openqa.selenium.By;
4 | import org.openqa.selenium.WebDriver;
5 | import org.openqa.selenium.WebElement;
6 | import org.openqa.selenium.chrome.ChromeDriver;
7 | import org.openqa.selenium.support.locators.RelativeLocator;
8 |
9 | public class ServerOpen {
10 | public static void main(String[] args) throws InterruptedException {
11 | WebDriver driver = new ChromeDriver();
12 |
13 | driver.get("https://www.facebook.com/");
14 |
15 | WebElement un = driver.findElement(RelativeLocator
16 | .with(By.tagName("input"))
17 | .above(By.id("pass"))
18 | );
19 | un.sendKeys("admin");
20 | driver.findElement(RelativeLocator
21 | .with(By.tagName("button"))
22 | .below(By.id("pass"))
23 | ).click();
24 |
25 | Thread.sleep(5000);
26 |
27 | driver.close();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_iframes/Slider.java:
--------------------------------------------------------------------------------
1 | package working_with_iframes;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.WebElement;
8 | import org.openqa.selenium.chrome.ChromeDriver;
9 | import org.openqa.selenium.interactions.Actions;
10 |
11 | public class Slider {
12 | public static void main(String[] args) throws InterruptedException {
13 | WebDriver driver = new ChromeDriver();
14 | driver.manage().window().maximize();
15 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
16 |
17 | driver.get("https://jqueryui.com/slider/");
18 |
19 | driver.switchTo().frame(0);
20 |
21 | WebElement slider = driver.findElement(By.id("slider"));
22 |
23 | Actions act = new Actions(driver);
24 | act.moveToElement(slider, 100, 0).click().build().perform();
25 |
26 | Thread.sleep(3000);
27 |
28 | driver.get("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select_multiple");
29 |
30 | WebElement frameElement = driver.findElement(By.id("iframeResult"));
31 |
32 | // driver.switchTo().frame(1);
33 | // driver.switchTo().frame("iframeResult");
34 | driver.switchTo().frame(frameElement);
35 |
36 | driver.findElement(By.cssSelector("input[type='submit']")).click();
37 |
38 | Thread.sleep(5000);
39 | driver.quit();
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_javascriptexecutor/Facebook.java:
--------------------------------------------------------------------------------
1 | package working_with_javascriptexecutor;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.JavascriptExecutor;
7 | import org.openqa.selenium.WebDriver;
8 | import org.openqa.selenium.WebElement;
9 | import org.openqa.selenium.chrome.ChromeDriver;
10 |
11 | public class Facebook {
12 | public static void main(String[] args) throws InterruptedException {
13 | WebDriver driver = new ChromeDriver();
14 | driver.manage().window().maximize();
15 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
16 |
17 | // driver.get("https://www.zomato.com/");
18 | JavascriptExecutor jse = (JavascriptExecutor) driver;
19 | jse.executeScript("window.location='https://www.facebook.com/';");
20 |
21 | WebElement un = driver.findElement(By.id("email"));
22 | WebElement loginBtn = driver.findElement(By.name("login"));
23 | WebElement cna = driver.findElement(By.linkText("Create new account"));
24 |
25 | String username = "admin";
26 | // un.sendKeys(username);
27 |
28 | // cna.click();
29 |
30 | // jse.executeScript("arguments[0].click();",loginBtn);
31 |
32 | jse.executeScript("arguments[0].click();",cna);
33 |
34 | // jse.executeScript("arguments[0].value='admin';", un);
35 | // jse.executeScript("arguments[0].value=arguments[1];", un, username);
36 |
37 | // click() => click()
38 | // sendKeys() => value=''
39 |
40 | // driver.findElement(By.xpath("//label[text()='Custom']")).click();
41 | // Thread.sleep(3000);
42 |
43 | WebElement cg = driver.findElement(By.id("custom_gender"));
44 | // cg.sendKeys("Male");
45 |
46 |
47 |
48 | Thread.sleep(5000);
49 | driver.quit();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_javascriptexecutor/Zomato.java:
--------------------------------------------------------------------------------
1 | package working_with_javascriptexecutor;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.JavascriptExecutor;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.chrome.ChromeDriver;
8 |
9 | public class Zomato {
10 | public static void main(String[] args) throws InterruptedException {
11 | WebDriver driver = new ChromeDriver();
12 | driver.manage().window().maximize();
13 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
14 |
15 | // driver.get("https://www.zomato.com/");
16 | JavascriptExecutor jse = (JavascriptExecutor) driver;
17 | jse.executeScript("window.location='https://www.zomato.com/';");
18 |
19 | Thread.sleep(500);
20 |
21 | jse.executeScript("window.scrollTo(0,100);");
22 |
23 | Thread.sleep(500);
24 |
25 | jse.executeScript("window.scrollBy(0,100);");
26 |
27 | Thread.sleep(500);
28 |
29 | jse.executeScript("window.scrollBy(0,100);");
30 |
31 | Thread.sleep(500);
32 |
33 | jse.executeScript("window.scrollBy(0,100);");
34 |
35 | Thread.sleep(500);
36 |
37 | jse.executeScript("window.scrollBy(0,100);");
38 |
39 | Thread.sleep(500);
40 |
41 | jse.executeScript("window.scrollBy(0,100);");
42 |
43 | System.out.println(jse.executeScript("return document.title;"));
44 |
45 | driver.quit();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_popups/Authentication.java:
--------------------------------------------------------------------------------
1 | package working_with_popups;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.WebDriver;
6 | import org.openqa.selenium.chrome.ChromeDriver;
7 |
8 | public class Authentication {
9 | public static void main(String[] args) throws InterruptedException {
10 | WebDriver driver = new ChromeDriver();
11 | driver.manage().window().maximize();
12 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
13 |
14 | driver.get("https://admin:admin@the-internet.herokuapp.com/basic_auth");
15 |
16 | Thread.sleep(3000);
17 | driver.quit();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_popups/FileUploadHandle.java:
--------------------------------------------------------------------------------
1 | package working_with_popups;
2 |
3 | import java.io.IOException;
4 | import java.time.Duration;
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.chrome.ChromeDriver;
8 |
9 | public class FileUploadHandle {
10 | public static void main(String[] args) throws InterruptedException, IOException {
11 | WebDriver driver = new ChromeDriver();
12 | driver.manage().window().maximize();
13 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
14 |
15 | driver.get("https://www.naukri.com/registration/createAccount?othersrcp=22636");
16 |
17 | driver.findElement(By.xpath("//h2[text()=\"I'm experienced\"]")).click();
18 | Thread.sleep(2000);
19 |
20 | // Step 1: Click on the "Upload Resume" button
21 | driver.findElement(By.xpath("//button[text()='Upload Resume']")).click();
22 |
23 | // Step 2: Run AutoIt script to handle popup
24 | Runtime.getRuntime().exec("./src/test/resources/uploadFile.exe");
25 |
26 | System.out.println("File uploaded successfully!");
27 |
28 | Thread.sleep(5000);
29 | driver.quit();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_popups/FileUploadHandleRobot.java:
--------------------------------------------------------------------------------
1 | package working_with_popups;
2 |
3 | import java.awt.AWTException;
4 | import java.awt.Rectangle;
5 | import java.awt.Robot;
6 | import java.awt.Toolkit;
7 | import java.awt.image.BufferedImage;
8 | import java.io.File;
9 | import java.io.IOException;
10 | import java.time.Duration;
11 |
12 | import javax.imageio.ImageIO;
13 |
14 | import org.openqa.selenium.By;
15 | import org.openqa.selenium.WebDriver;
16 | import org.openqa.selenium.chrome.ChromeDriver;
17 |
18 | public class FileUploadHandleRobot {
19 | public static void main(String[] args) throws InterruptedException, IOException, AWTException {
20 | WebDriver driver = new ChromeDriver();
21 | driver.manage().window().maximize();
22 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
23 |
24 | driver.get("https://www.naukri.com/registration/createAccount?othersrcp=22636");
25 |
26 | driver.findElement(By.xpath("//h2[text()=\"I'm experienced\"]")).click();
27 | Thread.sleep(2000);
28 |
29 | Robot robot = new Robot();
30 | Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
31 | BufferedImage image = robot.createScreenCapture(screenRect);
32 | ImageIO.write(image, "png", new File("./src/test/java/working_with_popups/Jenkins.png"));
33 |
34 |
35 | Thread.sleep(5000);
36 | driver.quit();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_popups/FileUploadIgnore.java:
--------------------------------------------------------------------------------
1 | package working_with_popups;
2 |
3 | import java.io.IOException;
4 | import java.time.Duration;
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.chrome.ChromeDriver;
8 |
9 | public class FileUploadIgnore {
10 | public static void main(String[] args) throws InterruptedException, IOException {
11 | WebDriver driver = new ChromeDriver();
12 | driver.manage().window().maximize();
13 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
14 |
15 | driver.get("https://www.naukri.com/registration/createAccount?othersrcp=22636");
16 |
17 | driver.findElement(By.xpath("//h2[text()=\"I'm experienced\"]")).click();
18 | Thread.sleep(2000);
19 |
20 | driver.findElement(By.id("resumeUpload")).sendKeys("C:\\Users\\User\\git\\A12-Basic-selenium\\A12-selenium-superstar\\src\\test\\java\\working_with_popups\\Jenkins.pdf");
21 |
22 | System.out.println("File uploaded successfully!");
23 |
24 | Thread.sleep(5000);
25 | driver.quit();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_popups/JSPopup.java:
--------------------------------------------------------------------------------
1 | package working_with_popups;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.Alert;
6 | import org.openqa.selenium.By;
7 | import org.openqa.selenium.WebDriver;
8 | import org.openqa.selenium.chrome.ChromeDriver;
9 |
10 | public class JSPopup {
11 | public static void main(String[] args) throws InterruptedException {
12 | WebDriver driver = new ChromeDriver();
13 | driver.manage().window().maximize();
14 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
15 |
16 | driver.get("https://demowebshop.tricentis.com/");
17 |
18 | driver.findElement(By.cssSelector("input[value='Search']")).click();
19 |
20 | Thread.sleep(2000);
21 |
22 | driver.switchTo().alert().accept();
23 |
24 |
25 | driver.get("https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_prompt");
26 |
27 | driver.switchTo().frame("iframeResult");
28 |
29 | driver.findElement(By.xpath("//button[text()='Try it']")).click();
30 |
31 | Alert ale = driver.switchTo().alert();
32 |
33 | ale.sendKeys("Dinga");
34 | ale.accept();
35 |
36 | Thread.sleep(2000);
37 | // driver.quit();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_popups/Jenkins.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AutomationWithPiyushhh/A12-selenium-superstars/01a497de31abf03ea50daf4b1740e7e9fbad2733/A12-selenium-superstar/src/test/java/working_with_popups/Jenkins.pdf
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_popups/Jenkins.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AutomationWithPiyushhh/A12-selenium-superstars/01a497de31abf03ea50daf4b1740e7e9fbad2733/A12-selenium-superstar/src/test/java/working_with_popups/Jenkins.png
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_popups/Notification.java:
--------------------------------------------------------------------------------
1 | package working_with_popups;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.WebDriver;
6 | import org.openqa.selenium.chrome.ChromeDriver;
7 | import org.openqa.selenium.chrome.ChromeOptions;
8 |
9 | public class Notification {
10 | public static void main(String[] args) throws InterruptedException {
11 |
12 |
13 | ChromeOptions setting = new ChromeOptions();
14 | // setting.addArguments("--disable-notifications");
15 | // setting.addArguments("--incognito");
16 | setting.addArguments("--start-maximized");
17 |
18 | WebDriver driver = new ChromeDriver(setting);
19 | // driver.manage().window().maximize();
20 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
21 |
22 | driver.get("https://www.easemytrip.com/");
23 |
24 |
25 |
26 | Thread.sleep(10000);
27 | // driver.quit();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_screenshots/FaceBook.java:
--------------------------------------------------------------------------------
1 | package working_with_screenshots;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 | import java.time.Duration;
6 |
7 | import org.openqa.selenium.By;
8 | import org.openqa.selenium.OutputType;
9 | import org.openqa.selenium.TakesScreenshot;
10 | import org.openqa.selenium.WebDriver;
11 | import org.openqa.selenium.WebElement;
12 | import org.openqa.selenium.chrome.ChromeDriver;
13 | import org.openqa.selenium.io.FileHandler;
14 |
15 | public class FaceBook {
16 | public static void main(String[] args) throws IOException, InterruptedException {
17 | WebDriver driver = new ChromeDriver();
18 | driver.manage().window().maximize();
19 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
20 |
21 | driver.get("https://www.facebook.com/");
22 |
23 | Thread.sleep(5000);
24 |
25 | // Taking ss of web page
26 | TakesScreenshot tks = (TakesScreenshot) driver;
27 | File src = tks.getScreenshotAs(OutputType.FILE);
28 | File dest = new File(
29 | "./errorShots/webpage.png");
30 |
31 | FileHandler.copy(src, dest);
32 |
33 | // Taking ss of web element => Login button
34 |
35 | WebElement facebook = driver.findElement(By.cssSelector("img[alt=\"Facebook\"]"));
36 | File source = facebook.getScreenshotAs(OutputType.FILE);
37 | File destination = new File(
38 | "./errorShots/webelement.png");
39 | FileHandler.copy(source, destination);
40 |
41 | System.out.println("Screenshot taken successfully!!!");
42 |
43 | Thread.sleep(3000);
44 | driver.quit();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_synchronization/CloseQuit.java:
--------------------------------------------------------------------------------
1 | package working_with_synchronization;
2 |
3 | import org.openqa.selenium.WebDriver;
4 | import org.openqa.selenium.chrome.ChromeDriver;
5 |
6 | public class CloseQuit {
7 | public static void main(String[] args) {
8 | WebDriver driver = new ChromeDriver();
9 |
10 |
11 | driver.close();
12 | driver.close();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_synchronization/Heroku.java:
--------------------------------------------------------------------------------
1 | package working_with_synchronization;
2 |
3 | import org.openqa.selenium.*;
4 | import org.openqa.selenium.chrome.ChromeDriver;
5 | import org.openqa.selenium.support.ui.FluentWait;
6 | import org.openqa.selenium.support.ui.Wait;
7 |
8 | import java.time.Duration;
9 | import java.util.function.Function;
10 |
11 | public class Heroku {
12 | public static void main(String[] args) {
13 | WebDriver driver = new ChromeDriver();
14 | driver.manage().window().maximize();
15 | driver.get("https://the-internet.herokuapp.com/dynamic_controls");
16 |
17 | // Click on Remove button
18 | driver.findElement(By.xpath("//form[@id='checkbox-example']/button")).click();
19 |
20 | // Create FluentWait instance
21 | Wait wait = new FluentWait<>(driver)
22 | .withTimeout(Duration.ofSeconds(2)) // total wait time
23 | .pollingEvery(Duration.ofSeconds(2)) // check every 2 seconds
24 | .ignoring(NoSuchElementException.class); // ignore if element not found
25 |
26 | // Use Function to repeatedly check for the element
27 | WebElement verify = wait.until(new Function() {
28 | public WebElement apply(WebDriver driver) {
29 | System.out.println("Checking for message element...");
30 | WebElement msg = driver.findElement(By.id("message"));
31 | if (msg.isDisplayed()) {
32 | System.out.println("Message found!");
33 | return msg;
34 | } else {
35 | return null; // keep waiting
36 | }
37 | }
38 | });
39 |
40 | System.out.println("Displayed Message: " + verify.getText());
41 | driver.quit();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_synchronization/Shoppersstack.java:
--------------------------------------------------------------------------------
1 | package working_with_synchronization;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.WebElement;
8 | import org.openqa.selenium.chrome.ChromeDriver;
9 | import org.openqa.selenium.support.ui.ExpectedConditions;
10 | import org.openqa.selenium.support.ui.WebDriverWait;
11 |
12 | public class Shoppersstack {
13 | public static void main(String[] args) throws InterruptedException {
14 | WebDriver driver = new ChromeDriver();
15 | driver.manage().window().maximize();
16 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
17 |
18 | driver.get("https://www.shoppersstack.com/products_page/24");
19 |
20 | Thread.sleep(10000);
21 | driver.findElement(By.id("Check Delivery")).sendKeys("201301");
22 |
23 | WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15));
24 |
25 | WebElement checkButton = driver.findElement(By.id("Check"));
26 |
27 | WebElement we = driver.findElement(By.id("Check"));
28 | wait.until(ExpectedConditions.visibilityOf(we));
29 | // wait.until(ExpectedConditions.elementToBeClickable(checkButton));
30 |
31 | checkButton.click();
32 | Thread.sleep(5000);
33 | driver.quit();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_synchronization/ShoppersstackFluentWait.java:
--------------------------------------------------------------------------------
1 | package working_with_synchronization;
2 |
3 | import java.time.Duration;
4 | import java.util.NoSuchElementException;
5 | import java.util.concurrent.TimeoutException;
6 |
7 | import org.openqa.selenium.By;
8 | import org.openqa.selenium.ElementClickInterceptedException;
9 | import org.openqa.selenium.WebDriver;
10 | import org.openqa.selenium.WebElement;
11 | import org.openqa.selenium.chrome.ChromeDriver;
12 | import org.openqa.selenium.support.ui.ExpectedConditions;
13 | import org.openqa.selenium.support.ui.FluentWait;
14 | import org.openqa.selenium.support.ui.WebDriverWait;
15 |
16 | public class ShoppersstackFluentWait {
17 | public static void main(String[] args) throws InterruptedException {
18 | WebDriver driver = new ChromeDriver();
19 | driver.manage().window().maximize();
20 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
21 |
22 | driver.get("https://www.shoppersstack.com/products_page/24");
23 |
24 | Thread.sleep(10000);
25 | driver.findElement(By.id("Check Delivery")).sendKeys("201301");
26 |
27 | WebElement checkButton = driver.findElement(By.id("Check"));
28 |
29 | // Explicit wait
30 | // WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15));
31 | // wait.until(ExpectedConditions.elementToBeClickable(checkButton));
32 |
33 | // Fluent wait
34 | FluentWait wait = new FluentWait(driver);
35 | wait.withTimeout(Duration.ofSeconds(15));
36 | wait.pollingEvery(Duration.ofMillis(1000));
37 |
38 | wait.until(ExpectedConditions.elementToBeClickable(checkButton));
39 |
40 | wait.ignoring(ElementClickInterceptedException.class);
41 |
42 | checkButton.click();
43 |
44 | Thread.sleep(5000);
45 | driver.quit();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_synchronization/TheInternet.java:
--------------------------------------------------------------------------------
1 | package working_with_synchronization;
2 |
3 | import java.time.Duration;
4 |
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.chrome.ChromeDriver;
8 |
9 | public class TheInternet {
10 | public static void main(String[] args) throws InterruptedException {
11 | WebDriver driver = new ChromeDriver();
12 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
13 |
14 | driver.get("https://the-internet.herokuapp.com/dynamic_controls");
15 |
16 | driver.findElement(By.xpath("//button[text()='Remove']")).click();
17 |
18 | // Thread.sleep(5000);
19 |
20 | driver.findElement(By.xpath("//button[text()='Add']")).click();
21 |
22 | Thread.sleep(3000);
23 | driver.quit();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_window_handling/FaceBook.java:
--------------------------------------------------------------------------------
1 | package working_with_window_handling;
2 |
3 | import java.time.Duration;
4 | import java.util.Set;
5 |
6 | import org.openqa.selenium.By;
7 | import org.openqa.selenium.WebDriver;
8 | import org.openqa.selenium.chrome.ChromeDriver;
9 |
10 | public class FaceBook {
11 | public static void main(String[] args) throws InterruptedException {
12 | WebDriver driver = new ChromeDriver();
13 | driver.manage().window().maximize();
14 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
15 |
16 | driver.get("https://www.facebook.com/");
17 |
18 | // Step 1> get the home address/Parent ID
19 | String PID = driver.getWindowHandle();
20 |
21 | // Step 2> perform the task which will open new window/s
22 | driver.findElement(By.linkText("Meta Pay")).click();
23 |
24 | // step 3> Get all the windows id/children IDs
25 | Set IDs = driver.getWindowHandles();
26 |
27 | // Step 4> Switch to particular window
28 | for (String i : IDs) {
29 | driver.switchTo().window(i);
30 |
31 | Thread.sleep(5000);
32 |
33 | if (driver.getTitle().contains("Meta")) {
34 |
35 | // Step 5> perform the task
36 | Thread.sleep(1000);
37 | driver.close();
38 | break;
39 | }
40 | }
41 |
42 | // Step 6> come back to home/Parent page
43 | // driver.switchTo().window(PID);
44 |
45 | Thread.sleep(5000);
46 | driver.close();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/java/working_with_window_handling/Shoppersstack.java:
--------------------------------------------------------------------------------
1 | package working_with_window_handling;
2 |
3 | import java.time.Duration;
4 | import java.util.Set;
5 |
6 | import org.openqa.selenium.By;
7 | import org.openqa.selenium.WebDriver;
8 | import org.openqa.selenium.chrome.ChromeDriver;
9 |
10 | public class Shoppersstack {
11 | public static void main(String[] args) throws InterruptedException {
12 | WebDriver driver = new ChromeDriver();
13 | driver.manage().window().maximize();
14 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
15 |
16 | driver.get("https://shoppersstack.com/products_page/51");
17 |
18 | Thread.sleep(10000);
19 |
20 | // Step 1> get the home address/Parent ID
21 | String PID = driver.getWindowHandle();
22 |
23 | // Step 2> perform the task which will open new window/s
24 | driver.findElement(By.id("compare")).click();
25 |
26 | // step 3> Get all the windows id/children IDs
27 | Set IDs = driver.getWindowHandles();
28 |
29 | // Step 4> Switch to particular window
30 | for (String i : IDs) {
31 | driver.switchTo().window(i);
32 | // Step 5> perform the task
33 | if (driver.getTitle().contains("mazon.in")) {
34 | Thread.sleep(2000);
35 | driver.close();
36 | }
37 | }
38 |
39 | // Step 6> come back to home/Parent page
40 | driver.switchTo().window(PID);
41 |
42 |
43 | Thread.sleep(5000);
44 | driver.quit();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/resources/TestNG.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AutomationWithPiyushhh/A12-selenium-superstars/01a497de31abf03ea50daf4b1740e7e9fbad2733/A12-selenium-superstar/src/test/resources/TestNG.pdf
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/resources/uploadFile.au3:
--------------------------------------------------------------------------------
1 | ; This script sets text into File Upload dialog and presses Open
2 | WinWaitActive("Open") ; Wait until the popup window with title "Open" appears
3 | Send("C:\Users\User\git\A12-Basic-selenium\A12-selenium-superstar\src\test\resources\TestNG.pdf") ; Path of file
4 | Send("{ENTER}") ; Press Enter
5 |
--------------------------------------------------------------------------------
/A12-selenium-superstar/src/test/resources/uploadFile.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AutomationWithPiyushhh/A12-selenium-superstars/01a497de31abf03ea50daf4b1740e7e9fbad2733/A12-selenium-superstar/src/test/resources/uploadFile.exe
--------------------------------------------------------------------------------