TestNG
This commit is contained in:
@@ -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 }}."
|
|
||||||
Generated
+2
-2
@@ -8,7 +8,7 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" project-jdk-name="openjdk-23" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/../BrushUpJava" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
Generated
+124
@@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Binary file not shown.
Binary file not shown.
@@ -3,11 +3,11 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>zacksolutions</groupId>
|
<groupId>zacksolutions</groupId>
|
||||||
<artifactId>SeleniumIntro</artifactId>
|
<artifactId>testNG_FrameWork</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SeleniumIntro</name>
|
<name>testNG_FrameWork</name>
|
||||||
<url>http://maven.apache.org</url>
|
<url>http://maven.apache.org</url>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -16,30 +16,28 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
|
||||||
<artifactId>junit</artifactId>
|
<groupId>org.testng</groupId>
|
||||||
<version>3.8.1</version>
|
<artifactId>testng</artifactId>
|
||||||
<scope>test</scope>
|
<version>7.10.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
|
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.seleniumhq.selenium</groupId>
|
<groupId>org.seleniumhq.selenium</groupId>
|
||||||
<artifactId>selenium-java</artifactId>
|
<artifactId>selenium-java</artifactId>
|
||||||
<version>4.24.0</version>
|
<version>4.25.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.testng</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>testng</artifactId>
|
||||||
<version>4.13.2</version>
|
<version>7.1.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<WebElement> itemsName = driver.findElements(By.cssSelector("h4[class$='product-name']"));
|
|
||||||
List<String> 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package zacksolutions;
|
||||||
|
|
||||||
|
public class FrameNG {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<WebElement> 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<WebElement> 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<WebElement> 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<String> tabs = driver.getWindowHandles();
|
|
||||||
Iterator<String> it = tabs.iterator();
|
|
||||||
while(it.hasNext()){
|
|
||||||
driver.switchTo().window(it.next());
|
|
||||||
System.out.println(driver.getTitle());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<String> tabs = driver.getWindowHandles();
|
|
||||||
Iterator<String> 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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
|
||||||
|
<suite name="All Test Suite">
|
||||||
|
<test verbose="2" preserve-order="true" name="/home/ilyes/LearnSelenium/testNG_FrameWork">
|
||||||
|
<classes>
|
||||||
|
<class name="zacksolutions.TestNGDiffClass">
|
||||||
|
</class>
|
||||||
|
<class name="zacksolutions.TestHomePage">
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
</test>
|
||||||
|
<test name="DiffTest">
|
||||||
|
<classes>
|
||||||
|
<class name="zacksolutions.TestNGClass">
|
||||||
|
</class>
|
||||||
|
<class name="zacksolutions.TestLoginPage">
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
</test>
|
||||||
|
</suite>
|
||||||
Reference in New Issue
Block a user