AbhreshSugandhi / Edureka_27thMay

0 stars 1 forks source link

Issue with ExplicitWait Script #2

Closed jayanaidu33 closed 5 years ago

jayanaidu33 commented 5 years ago

The below script is not working

package day4;

import java.util.concurrent.TimeUnit; import java.util.function.Function;

import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.Clock; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait;

public class Selenium30 {

public static void main(String args[])
{
    System.setProperty("webdriver.chrome.driver", "C:\\SeleniumTraining\\Installation Stuff\\Driver\\chromedriver.exe");
    ChromeDriver driver=new ChromeDriver();

    /*driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
    driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);*/
    driver.get("https://in.ebay.com/");
            Actions act=new Actions(driver);

            WebDriverWait wait=new WebDriverWait(driver,10);

            WebElement ele=driver.findElement(By.linkText("Motors"));

            wait.until(ExpectedConditions.visibilityOfElementLocated(ele));

            /*act.moveToElement(driver.findElement(By.linkText("Motors"))).moveToElement(driver.findElement(By.linkText("Classics"))).click().build().perform();*/
            act.moveToElement(driver.findElement(By.linkText("Motors"))).build().perform();
            act.moveToElement(driver.findElement(By.linkText("Classics"))).click().build().perform();

            driver.manage().window().maximize();}

}

It says Cast Arguement1 to By.

Even after Casting I am getting below error

Exception in thread "main" java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebElement cannot be cast to org.openqa.selenium.By at day4.Selenium30.main(Selenium30.java:31)

AbhreshSugandhi commented 5 years ago

1) Where is WebDriver Implemented? - read the google doc in day 4 have added the explaination. 2) did you resolved the error on the wait command- The method visibilityOfElementLocated(By) in the type ExpectedConditions is not applicable for the arguments (WebElement) 3) Read and understand the class of Expected Conditions