sel_progress

This commit is contained in:
dadgam3er 2024-09-19 18:02:36 -04:00
parent daa6758940
commit fd65bf087c
6 changed files with 93 additions and 14 deletions

View File

@ -9,6 +9,6 @@
</option>
</component>
<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>
</project>

View 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);
}
}

View File

@ -4,8 +4,8 @@ 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.lang.reflect.Array;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
@ -13,17 +13,21 @@ 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) throws InterruptedException {
System.setProperty("web-driver.gecko.driver", "/home/ilyes/LearnSelenium/DemoProject/drivers/geckodriver");
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);
Thread.sleep(3000);
try {
getItems();
checkOut();
} catch (InterruptedException e) {
e.printStackTrace();
} 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 {
List<WebElement> itemsName = driver.findElements(By.cssSelector("h4[class$='product-name']"));
List<String> listOfItems = Arrays.asList(items);

View File

@ -15,18 +15,16 @@ public class Locators {
public static WebDriver driver;
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");
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();

View 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");
}
}

View File

@ -4,10 +4,16 @@ import org.junit.Assert;
import org.junit.Test;
public class TitleTest {
@Test
/* @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!");
}
}