sel_progress
This commit is contained in:
parent
daa6758940
commit
fd65bf087c
@ -9,6 +9,6 @@
|
|||||||
</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_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/../BrushUpJava" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
48
src/main/java/zacksolutions/Ajax.java
Normal file
48
src/main/java/zacksolutions/Ajax.java
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,8 +4,8 @@ import org.openqa.selenium.By;
|
|||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||||
|
import org.openqa.selenium.interactions.Actions;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -13,17 +13,21 @@ import java.util.List;
|
|||||||
public class AmazonQuestion {
|
public class AmazonQuestion {
|
||||||
public static WebDriver driver;
|
public static WebDriver driver;
|
||||||
public static String[] items = { "Brocolli", "Beetroot", "Beans", "Carrot", "Potato" };
|
public static String[] items = { "Brocolli", "Beetroot", "Beans", "Carrot", "Potato" };
|
||||||
|
public static String code = "";
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) {
|
||||||
System.setProperty("web-driver.gecko.driver", "/home/ilyes/LearnSelenium/DemoProject/drivers/geckodriver");
|
}
|
||||||
|
|
||||||
|
public static void Initialize() throws InterruptedException {
|
||||||
|
|
||||||
|
System.setProperty("web-driver.gecko.driver", "user.dir" + "LearnSelenium/DemoProject/drivers/geckodriver");
|
||||||
driver = new FirefoxDriver();
|
driver = new FirefoxDriver();
|
||||||
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
|
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
|
||||||
String url = "https://rahulshettyacademy.com/seleniumPractise/";
|
String url = "https://rahulshettyacademy.com/seleniumPractise/";
|
||||||
driver.get(url);
|
driver.get(url);
|
||||||
Thread.sleep(3000);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getItems();
|
getItems();
|
||||||
|
checkOut();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@ -32,6 +36,15 @@ public class AmazonQuestion {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
public static void getItems() throws InterruptedException {
|
||||||
List<WebElement> itemsName = driver.findElements(By.cssSelector("h4[class$='product-name']"));
|
List<WebElement> itemsName = driver.findElements(By.cssSelector("h4[class$='product-name']"));
|
||||||
List<String> listOfItems = Arrays.asList(items);
|
List<String> listOfItems = Arrays.asList(items);
|
||||||
|
|||||||
@ -15,18 +15,16 @@ public class Locators {
|
|||||||
public static WebDriver driver;
|
public static WebDriver driver;
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException, IOException {
|
public static void main(String[] args) throws InterruptedException, IOException {
|
||||||
Locators lc = new Locators();
|
|
||||||
lc.loginPage();
|
|
||||||
|
|
||||||
getScreenShot(driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loginPage() throws InterruptedException {
|
|
||||||
System.setProperty("web-driver.gecko.driver", "/home/ilyes/LearnSelenium/DemoProject/drivers/geckodriver");
|
System.setProperty("web-driver.gecko.driver", "/home/ilyes/LearnSelenium/DemoProject/drivers/geckodriver");
|
||||||
driver = new FirefoxDriver();
|
driver = new FirefoxDriver();
|
||||||
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
|
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
|
||||||
String url = "https://rahulshettyacademy.com/locatorspractice/";
|
String url = "https://rahulshettyacademy.com/locatorspractice/";
|
||||||
driver.get(url);
|
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[id='inputUsername']")).sendKeys("Zakaria");
|
||||||
driver.findElement(By.cssSelector("input[name='inputPassword']")).sendKeys("Zakaria");
|
driver.findElement(By.cssSelector("input[name='inputPassword']")).sendKeys("Zakaria");
|
||||||
driver.findElement(By.cssSelector("button[type='submit']")).click();
|
driver.findElement(By.cssSelector("button[type='submit']")).click();
|
||||||
|
|||||||
14
src/test/java/zacksolutions/HoverTest.java
Normal file
14
src/test/java/zacksolutions/HoverTest.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,10 +4,16 @@ import org.junit.Assert;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TitleTest {
|
public class TitleTest {
|
||||||
@Test
|
/* @Test
|
||||||
public void TestTitle() throws InterruptedException {
|
public void TestTitle() throws InterruptedException {
|
||||||
GuestBookWebPage.getTitle();
|
GuestBookWebPage.getTitle();
|
||||||
Assert.assertEquals("Guest Book", GuestBookWebPage.title);
|
Assert.assertEquals("Guest Book", GuestBookWebPage.title);
|
||||||
System.out.println("The expected is: Guest Book and the actual is: " + 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!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user