鼠标悬停不使用testng

时间:2017-02-09 02:46:33

标签: selenium

我正在尝试自动登录amazon.in,但鼠标悬停影响不起作用。     问题: - 我创建了两个类声明和调用类。在声明类中我声明了所有元素,并且在调用类中我已经调用了所有元素。但悬停鼠标悬停不起作用。

Declaring class

package declaringClassAmazonOrder;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
import org.openqa.selenium.interactions.Actions;


public class declaringClass {

    WebDriver driver;
    //Actions act=new Actions(driver);
    public declaringClass(WebDriver driver) {
        this.driver=driver;
    }
    //hovering the mouse over login button
    @FindBy(how=How.XPATH, using=("//*[@id='nav-link-yourAccount']"))
    WebElement helloSignIn;

    //clicking on login button
    @FindBy(xpath="//*[@id='nav-flyout-ya-signin']/a/span")
    WebElement signIn;

    //user clicks on email
    @FindBy(id="ap_email")
    WebElement email;

    //user clicks on password
    @FindBy(id="ap_password")
    WebElement password;

    //User clicks on submit 
    @FindBy(id="signInSubmit")
    WebElement login;

    //Selecting Amazon prime check box
    @FindBy(xpath="//*[@id='ref_10440598031']/li/a")
    WebElement prime;

    //Selecting Amazon fulfilled check box
    @FindBy(xpath="//*[@id='ref_10440596031']/li/a")
    WebElement fulFilled;

    //Selecting the product, after selecting the product user needs to switch 
    @FindBy(xpath="//*[@id='result_0']/div/div[2]/div/div/a/img")
    WebElement product;

    //Choose phone color after selecting the product
    @FindBy(xpath="//*[@id='a-autoid-12-announce']/div/div[1]/img")
    WebElement phoneColor;

    //click on add to card button
    @FindBy(xpath="//*[@id='add-to-cart-button']")
    WebElement addToCard;

    //click on proceed to check out button
    @FindBy(xpath="//*[@id='hlb-ptc-btn-native']")
    WebElement proceedToCheckOut;

    //Select delivery address using zip code
    @FindBy(id="searchCriterion.storeZip")
    WebElement zipcodeRadioButton;

    //Enter Zip code
    @FindBy(id="storeZip")
    WebElement enterZipCode;

    //clicking on search buttonx`
    @FindBy(xpath="//*[@id='legacy-non-converged-locker-find']/form/table/tbody/tr[9]/td/div/input")
    WebElement searchButton;

public WebElement helloSignIn1()
    {return helloSignIn;
    }

    public WebElement signIn()
    {System.out.println("page click");
        return signIn;
    }

    public WebElement enterEmail()
    {System.out.println("");
         return email;
    }

    public WebElement enterPassword()
    {
        return password;
    }

    public WebElement loginAmazon()
    {return login;
    }

    public WebElement checkPrime()
    {return prime;
    }

    public WebElement checkfulFilled()
    {return fulFilled;
    }

    public WebElement selectProduct()
    {
        return product;
    }

    public WebElement selectPhoneColor()
    {return phoneColor;
    }

    public WebElement addProductToCart()
    {   
        return addToCard;
    }

    public WebElement checkOut()
    {return proceedToCheckOut;
    }

    public WebElement checkZipCodeRadioButton()
    {return zipcodeRadioButton;
    }

    public WebElement enterZipCodeValue()
    {return enterZipCode;
    }

    public WebElement clickSearchButton()
    {return searchButton;
    }
}


package callingClass1;
import declaringClassAmazonOrder.declaringClass;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.interactions.Actions;
import BrowserToOrder.selectBrowser;

public class callingClass {
    @Test()
    public void orderProduct() throws InterruptedException
    {   
        System.setProperty("webdriver.chrome.driver", "C://chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        Actions ac= new Actions(driver);
        driver.manage().window().maximize();
        driver.get("https://www.amazon.in");
        declaringClass dc=new declaringClass(driver);
        PageFactory.initElements(driver,declaringClass.class);  
        Thread.sleep(1000);
        System.out.println("before mouse hover");
        ac.moveToElement(dc.helloSignIn1()).build().perform();
        Thread.sleep(1000);
        System.out.println("after mouse hover");

    /*  wd.until(ExpectedConditions.elementToBeClickable(dc.signIn())).click();
        dc.signIn().click();
        dc.enterEmail().sendKeys("abc@abc.com");
        dc.enterPassword().sendKeys("anc");
        dc.loginAmazon().click();
        dc.checkPrime().click();
        dc.checkfulFilled().click();
        dc.selectProduct().click();
        dc.selectPhoneColor().click();
        dc.checkOut().click();
        dc.checkZipCodeRadioButton().click();
        dc.enterZipCodeValue().sendKeys("123456");
        dc.clickSearchButton().click();
        */
    }
}

0 个答案:

没有答案