package Techniques.Actions;

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.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.asserts.SoftAssert;

import java.time.Duration;

public class ActionsMethods {

    public static void main(String[] args) {
        WebDriver obj = new FirefoxDriver();
        obj.get("https://www.amazon.com/");

        //Creating Action Class.

        Actions mouse = new Actions(obj);

        // Wait used for create explicit wait.

        WebDriverWait wait = new WebDriverWait(obj, Duration.ofSeconds(5));


        obj.manage().window().maximize();

        // creating web Element.
        WebElement locator= obj.findElement(By.id("nav-link-accountList"));
        WebElement navbar = wait.until(ExpectedConditions.elementToBeClickable(locator));

        mouse.moveToElement(navbar).build().perform();




        //Creating WebElement

        WebElement search= obj.findElement(By.id("twotabsearchtextbox"));


        // passing key in capital letter.

        wait.until(ExpectedConditions.elementToBeClickable(search));

        mouse.moveToElement(search).click().keyDown(Keys.SHIFT).sendKeys("Hello").doubleClick().build().perform();


        // scrolling dowwn.

        mouse.scrollByAmount(0,4000).perform(); // will scroll down 600px.





       // String values= obj.findElement(By.xpath("//div[@id='CardInstanceSJR_RNu0KrfMtMjmIWfcTw']/div/div/h2/span")).getText();

       // System.out.println("The Value present at there is: "+values);

        SoftAssert softassert = new SoftAssert();

        softassert.assertEquals("hi kazi","ho");

        mouse.scrollByAmount(0,-4000).perform();

        softassert.assertAll(); // it will scroll up 300px.



    }

}
