diff --git a/.gitea/workflows/SeleniumAction.yaml b/.gitea/workflows/SeleniumAction.yaml deleted file mode 100644 index c537cc6..0000000 --- a/.gitea/workflows/SeleniumAction.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: Gitea Actions Demo -run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 -on: [push] - -jobs: - Explore-Gitea-Actions: - runs-on: ubuntu-latest - steps: - - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: Check out repository code - uses: actions/checkout@v4 - - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ gitea.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." diff --git a/.idea/misc.xml b/.idea/misc.xml index 3794b06..890a206 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ - - + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/drivers/chromedriver b/drivers/chromedriver deleted file mode 100755 index 47350a7..0000000 Binary files a/drivers/chromedriver and /dev/null differ diff --git a/drivers/geckodriver b/drivers/geckodriver deleted file mode 100755 index c525beb..0000000 Binary files a/drivers/geckodriver and /dev/null differ diff --git a/pom.xml b/pom.xml index b46da0f..284f4ef 100644 --- a/pom.xml +++ b/pom.xml @@ -3,11 +3,11 @@ 4.0.0 zacksolutions - SeleniumIntro + testNG_FrameWork 1.0-SNAPSHOT jar - SeleniumIntro + testNG_FrameWork http://maven.apache.org @@ -16,30 +16,28 @@ - junit - junit - 3.8.1 - test + + org.testng + testng + 7.10.2 + test org.seleniumhq.selenium selenium-java - 4.24.0 + 4.25.0 - org.apache.maven.plugins maven-surefire-plugin 3.5.0 - - junit - junit - 4.13.2 + org.testng + testng + 7.1.0 test - diff --git a/screenshot.png b/screenshot.png deleted file mode 100644 index 31c7e68..0000000 Binary files a/screenshot.png and /dev/null differ diff --git a/src/main/java/zacksolutions/Ajax.java b/src/main/java/zacksolutions/Ajax.java deleted file mode 100644 index 03ca260..0000000 --- a/src/main/java/zacksolutions/Ajax.java +++ /dev/null @@ -1,48 +0,0 @@ -package zacksolutions; - -import java.time.Duration; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -/** - * Ajax - */ -public class Ajax { - - public static WebDriver driver; - public static String hoverText; - - public static void main(String[] args) throws InterruptedException { - - Initialize(); - } - - public static void Initialize() throws InterruptedException { - System.setProperty("web-driver.gecko.driver", "user.dir" + "LearnSelenium/DemoProject/drivers/geckodriver"); - driver = new FirefoxDriver(); - driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5)); - String url = "https://www.amazon.com/"; - driver.get(url); - try { - Actionz(); - } finally { - driver.close(); - } - } - - public static void Actionz() { - Actions actions = new Actions(driver); - WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(20)); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#nav-link-accountList"))); - WebElement hover = driver.findElement(By.cssSelector("#nav-link-accountList")); - actions.moveToElement(hover); - hoverText = driver.findElement(By.cssSelector(".sc-ktJbId.bSNqcv")).getText(); - System.out.println(hoverText); - } -} diff --git a/src/main/java/zacksolutions/AmazonQuestion.java b/src/main/java/zacksolutions/AmazonQuestion.java deleted file mode 100644 index a1f09f3..0000000 --- a/src/main/java/zacksolutions/AmazonQuestion.java +++ /dev/null @@ -1,63 +0,0 @@ -package zacksolutions; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.interactions.Actions; - -import java.time.Duration; -import java.util.Arrays; -import java.util.List; - -public class AmazonQuestion { - public static WebDriver driver; - public static String[] items = { "Brocolli", "Beetroot", "Beans", "Carrot", "Potato" }; - public static String code = ""; - - public static void main(String[] args) { - } - - public static void Initialize() throws InterruptedException { - - System.setProperty("web-driver.gecko.driver", "user.dir" + "LearnSelenium/DemoProject/drivers/geckodriver"); - driver = new FirefoxDriver(); - driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5)); - String url = "https://rahulshettyacademy.com/seleniumPractise/"; - driver.get(url); - try { - getItems(); - checkOut(); - } catch (InterruptedException e) { - e.printStackTrace(); - } finally { - driver.close(); - } - - } - - public static void checkOut() { - driver.findElement(By.xpath("//a[@class='cart-icon']/img")).click(); - driver.findElement(By.xpath("//div[@class='action-block']/button")).click(); - driver.findElement(By.cssSelector(".promoCode")).sendKeys("rahulshettyacademy"); - driver.findElement(By.cssSelector(".promoBtn")).click(); - code = driver.findElement(By.cssSelector(".promoInfo")).getText(); - System.out.println(code); - } - - public static void getItems() throws InterruptedException { - List itemsName = driver.findElements(By.cssSelector("h4[class$='product-name']")); - List listOfItems = Arrays.asList(items); - int lastItem = 0; - for (int i = 0; i < itemsName.size(); i++) { - String item = itemsName.get(i).getText().split(" - ")[0].trim(); - if (listOfItems.contains(item)) { - driver.findElements(By.xpath("//div[@class='product-action']/button")).get(i).click(); - lastItem++; - if (lastItem == listOfItems.size()) { - break; - } - } - } - } -} diff --git a/src/main/java/zacksolutions/FrameNG.java b/src/main/java/zacksolutions/FrameNG.java new file mode 100644 index 0000000..90c9976 --- /dev/null +++ b/src/main/java/zacksolutions/FrameNG.java @@ -0,0 +1,7 @@ +package zacksolutions; + +public class FrameNG { + public static void main(String[] args) { + + } +} diff --git a/src/main/java/zacksolutions/GuestBookWebPage.java b/src/main/java/zacksolutions/GuestBookWebPage.java deleted file mode 100644 index 5566334..0000000 --- a/src/main/java/zacksolutions/GuestBookWebPage.java +++ /dev/null @@ -1,25 +0,0 @@ -package zacksolutions; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.firefox.FirefoxDriver; - -public class GuestBookWebPage { - public static String title; - - public static void main(String[] args) { - } - - public static void getTitle() throws InterruptedException { - // System.setProperty("web-driver.gecko.driver","/home/ilyes/mvnAction/SeleniumIntro/drivers/chromedriver"); - System.setProperty("web-driver.gecko.driver", "/home/ilyes/mvnAction/SeleniumIntro/drivers/geckodriver"); - WebDriver driver = new FirefoxDriver(); - // WebDriver driver = new ChromeDriver(); - driver.get("https://zenful.cloud/"); - title = driver.getTitle(); - driver.findElement(By.id("message")).sendKeys("4 8 15 16 23 42"); - driver.findElement(By.xpath("//button[normalize-space()='Add message']")).click(); - Thread.sleep(3000); - driver.close(); - } -} diff --git a/src/main/java/zacksolutions/Locators.java b/src/main/java/zacksolutions/Locators.java deleted file mode 100644 index 73327f8..0000000 --- a/src/main/java/zacksolutions/Locators.java +++ /dev/null @@ -1,64 +0,0 @@ -package zacksolutions; - -import org.apache.maven.surefire.shared.io.FileUtils; -import org.openqa.selenium.By; -import org.openqa.selenium.OutputType; -import org.openqa.selenium.TakesScreenshot; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.firefox.FirefoxDriver; - -import java.io.File; -import java.io.IOException; -import java.time.Duration; - -public class Locators { - public static WebDriver driver; - - public static void main(String[] args) throws InterruptedException, IOException { - System.setProperty("web-driver.gecko.driver", "/home/ilyes/LearnSelenium/DemoProject/drivers/geckodriver"); - driver = new FirefoxDriver(); - driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5)); - String url = "https://rahulshettyacademy.com/locatorspractice/"; - driver.get(url); - loginPage(); - getScreenShot(driver); - } - - public static void loginPage() throws InterruptedException { - driver.findElement(By.cssSelector("input[id='inputUsername']")).sendKeys("Zakaria"); - driver.findElement(By.cssSelector("input[name='inputPassword']")).sendKeys("Zakaria"); - driver.findElement(By.cssSelector("button[type='submit']")).click(); - String Err = driver.findElement(By.cssSelector("p.error")).getText(); - System.out.println(Err); - driver.findElement(By.linkText("Forgot your password?")).click(); - driver.findElement(By.xpath("//input[@placeholder='Name']")).sendKeys("Desmond"); - driver.findElement(By.xpath("//input[@placeholder='Email']")).sendKeys("hdesmond@island.con"); - driver.findElement(By.cssSelector("input[placeholder='Phone Number']")).sendKeys("5551118888"); - Thread.sleep(1000); - driver.findElement(By.cssSelector(".reset-pwd-btn")).click(); - System.out.println(""); - String newUser = driver.findElement(By.cssSelector("form p")).getText(); - System.out.println(newUser); - String passw = "rahulshettyacademy"; - System.out.println("New User Created please enter the password: " + passw); - Thread.sleep(1000); - driver.findElement(By.cssSelector(".go-to-login-btn")).click(); - Thread.sleep(1000); - driver.findElement(By.cssSelector("input[id='inputUsername']")).sendKeys("Desmond"); - driver.findElement(By.cssSelector("input[placeholder='Password']")).sendKeys(passw); - driver.findElement(By.xpath("//input[@id='chkboxOne']")).click(); - driver.findElement(By.xpath("//input[@id='chkboxTwo']")).click(); - driver.findElement(By.cssSelector("button[type='submit']")).click(); - Thread.sleep(1000); - String homePage = driver.getTitle(); - System.out.println(homePage); - Thread.sleep(2000); - } - - public static void getScreenShot(WebDriver driver) throws IOException { - File src = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); - FileUtils.copyFile(src, new File("/home/ilyes/SeleniumPractice/SeleniumIntro/screenshot.png")); - System.out.println("Picture taken... Please check your forlder"); - driver.close(); - } -} diff --git a/src/main/java/zacksolutions/Scope.java b/src/main/java/zacksolutions/Scope.java deleted file mode 100644 index c1b2f55..0000000 --- a/src/main/java/zacksolutions/Scope.java +++ /dev/null @@ -1,65 +0,0 @@ -package zacksolutions; - -import java.time.Duration; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.support.ui.ExpectedCondition; -import org.openqa.selenium.support.ui.WebDriverWait; - -public class Scope { - - public static WebDriver driver; - - public static void main(String[] args) throws InterruptedException { - Initialize(); - } - - public static void Initialize() throws InterruptedException { - System.setProperty("web-driver.gecko.driver", "user.dir" + "LearnSelenium/DemoProject/drivers/geckodriver"); - driver = new FirefoxDriver(); - driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5)); - String url = "https://qaclickacademy.com/practice.php"; - driver.get(url); - try { - linksCount(); - } finally { - driver.quit(); - } - } - - public static void linksCount() throws InterruptedException { - //all the links in the home page - List linkC = driver.findElements(By.tagName("a")); - System.out.println("The full page links count is: " + linkC.size()); - - //all links in the pageFooter - WebElement footdriver = driver.findElement(By.xpath("//div[@id='gf-BIG']")); - List footLinks = footdriver.findElements(By.tagName("a")); - System.out.println("The footer pages links amount to: " + footLinks.size()); - - //all the links in the first column - WebElement columnDriver = footdriver.findElement(By.xpath("//div/table/tbody/tr/td[1]/ul")); - List columnLinks = columnDriver.findElements(By.tagName("a")); - System.out.println("The column links amount to: " + columnLinks.size()); - - //Open each link in the column - for(int i = 1; i < columnLinks.size(); i ++){ - String clickON = Keys.chord(Keys.CONTROL, Keys.ENTER); - columnDriver.findElements(By.tagName("a")).get(i).sendKeys(clickON); - Thread.sleep(5000); - } - Set tabs = driver.getWindowHandles(); - Iterator it = tabs.iterator(); - while(it.hasNext()){ - driver.switchTo().window(it.next()); - System.out.println(driver.getTitle()); - } - } -} diff --git a/src/main/java/zacksolutions/SwitchWin.java b/src/main/java/zacksolutions/SwitchWin.java deleted file mode 100644 index 865a40b..0000000 --- a/src/main/java/zacksolutions/SwitchWin.java +++ /dev/null @@ -1,64 +0,0 @@ -package zacksolutions; - -import java.time.Duration; -import java.util.Iterator; -import java.util.Set; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.firefox.FirefoxDriver; - -/** - * SwitchWin - */ -public class SwitchWin { - - public static WebDriver driver; - public static String email = ""; - - public static void main(String[] args) throws InterruptedException { - - Initialize(); - } - - public static void Initialize() throws InterruptedException { - System.setProperty("web-driver.gecko.driver", "user.dir" + "LearnSelenium/DemoProject/drivers/geckodriver"); - driver = new FirefoxDriver(); - driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5)); - String url = "https://rahulshettyacademy.com/loginpagePractise/#"; - driver.get(url); - try { - loginPage(); - userInput(); - } finally { - Thread.sleep(6000); - driver.quit(); - } - } - - public static void loginPage() throws InterruptedException { - driver.findElement(By.cssSelector(".blinkingText")).click(); - Set tabs = driver.getWindowHandles(); - Iterator it = tabs.iterator(); - String parentTab = it.next(); - String childTab = it.next(); - driver.switchTo().window(childTab); - String []phrase = driver.findElement(By.cssSelector(".im-para.red")).getText().split(" "); - for (int i = 0; i < phrase.length; i++) { - if(phrase[i].contains("@")){ - email = phrase[i].trim(); - } - } - System.out.println("Please use the followoing email: " + email); - driver.switchTo().window(parentTab); - } - public static void userInput() throws InterruptedException { - driver.findElement(By.cssSelector("#username")).sendKeys("rahulshettyacademy"); - driver.findElement(By.cssSelector("#password")).sendKeys("learning"); - driver.findElement(By.xpath("//label[2]//span[2]")).click(); - driver.findElement(By.cssSelector(".btn.btn-success")).click(); - driver.findElement(By.xpath("//input[@id='terms']")).click(); - driver.findElement((By.cssSelector(".btn.btn-info.btn-md"))).click(); - System.out.println(driver.getTitle()); - } -} diff --git a/src/test/java/zacksolutions/HoverTest.java b/src/test/java/zacksolutions/HoverTest.java deleted file mode 100644 index 377f07f..0000000 --- a/src/test/java/zacksolutions/HoverTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package zacksolutions; - -import org.junit.Assert; -import org.junit.Test; - -public class HoverTest { - @Test - public void testHover() throws InterruptedException { - Ajax.Initialize(); - Ajax.Actionz(); - Assert.assertEquals("Who's shopping? Select a profile.", Ajax.hoverText); - System.out.println("Test confirmed"); - } -} diff --git a/src/test/java/zacksolutions/TestHomePage.java b/src/test/java/zacksolutions/TestHomePage.java new file mode 100644 index 0000000..2dc5b16 --- /dev/null +++ b/src/test/java/zacksolutions/TestHomePage.java @@ -0,0 +1,32 @@ +package zacksolutions; + +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +public class TestHomePage { + + @Test + public static void testCaseSixteen() { + System.out.println("Debug the sixteenth case"); + } + + @Test + public static void testCaseSeventeen() { + System.out.println("Debug the seventeenth case"); + } + + @Test + public static void testCaseEighteen() { + System.out.println("Debug the eighteenth case"); + } + + @Test + public static void testCaseNineteen() { + System.out.println("Debug the nineteenth case"); + } + + @BeforeTest + public static void testCaseTwenty() { + System.out.println("Debug the twentieth case ### BEFORE TEST"); + } +} diff --git a/src/test/java/zacksolutions/TestLoginPage.java b/src/test/java/zacksolutions/TestLoginPage.java new file mode 100644 index 0000000..b76a30b --- /dev/null +++ b/src/test/java/zacksolutions/TestLoginPage.java @@ -0,0 +1,30 @@ +package zacksolutions; + +import org.testng.annotations.Test; + +public class TestLoginPage { + @Test + public static void testCaseEleven() { + System.out.println("Debug the eleventh case"); + } + + @Test + public static void testCaseTwelve() { + System.out.println("Debug the twelfth case"); + } + + @Test + public static void testCaseThirteen() { + System.out.println("Debug the thirteenth case"); + } + + @Test + public static void testCaseFourteen() { + System.out.println("Debug the fourteenth case"); + } + + @Test + public static void testCaseFifteen() { + System.out.println("Debug the fifteenth case"); + } +} diff --git a/src/test/java/zacksolutions/TestNGClass.java b/src/test/java/zacksolutions/TestNGClass.java new file mode 100644 index 0000000..bc0a08a --- /dev/null +++ b/src/test/java/zacksolutions/TestNGClass.java @@ -0,0 +1,30 @@ +package zacksolutions; + +import org.testng.annotations.AfterTest; +import org.testng.annotations.Test; + +public class TestNGClass { + @AfterTest + public static void testCaseOne(){ + System.out.println("Debug the firtst case ### AFTER TEST ###"); + } + + @Test + public void testCaseTwo(){ + System.out.println("Debugging the second case"); + } + @Test + public static void testCaseThree() { + System.out.println("Debug the third case"); + } + + @Test + public static void testCaseFour() { + System.out.println("Debug the fourth case"); + } + + @Test + public static void testCaseFive() { + System.out.println("Debug the fifth case"); + } +} diff --git a/src/test/java/zacksolutions/TestNGDiffClass.java b/src/test/java/zacksolutions/TestNGDiffClass.java new file mode 100644 index 0000000..9cda989 --- /dev/null +++ b/src/test/java/zacksolutions/TestNGDiffClass.java @@ -0,0 +1,29 @@ +package zacksolutions; + +import org.testng.annotations.Test; + +public class TestNGDiffClass { + @Test + public void testCaseSix(){ + System.out.println("Debug the sixteenth case"); + } + @Test + public static void testCaseSeven() { + System.out.println("Debug the seventh case"); + } + + @Test + public static void testCaseEight() { + System.out.println("Debug the eighth case"); + } + + @Test + public static void testCaseNine() { + System.out.println("Debug the ninth case"); + } + + @Test + public static void testCaseTen() { + System.out.println("Debug the tenth case"); + } +} diff --git a/src/test/java/zacksolutions/TitleTest.java b/src/test/java/zacksolutions/TitleTest.java deleted file mode 100644 index 0628a06..0000000 --- a/src/test/java/zacksolutions/TitleTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package zacksolutions; - -import org.junit.Assert; -import org.junit.Test; - -public class TitleTest { - /* @Test - public void TestTitle() throws InterruptedException { - GuestBookWebPage.getTitle(); - Assert.assertEquals("Guest Book", GuestBookWebPage.title); - System.out.println("The expected is: Guest Book and the actual is: " + GuestBookWebPage.title); - }*/ - //@Test - public void checkOut() throws InterruptedException { - AmazonQuestion.Initialize(); - Assert.assertEquals("Code applied ..!", AmazonQuestion.code); - System.out.println("CODE APPLIED SUCCESSFULLY!"); - } -} diff --git a/testng.xml b/testng.xml new file mode 100644 index 0000000..17c9f13 --- /dev/null +++ b/testng.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file