Search code examples
javaseleniumwebdriverqaf

ClassCastException on Updating to Selenium 3.4


We are using QAF for functional test automation. We recently upgraded selenium version from 3.3.1 to 3.4.0 and it started giving following error at some places.

Caused by: java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebElement cannot be cast to com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebElement
at com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver.findElementByCssSelector(QAFExtendedWebDriver.java:366)
at com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver.findElementByCssSelector(QAFExtendedWebDriver.java:1)
at org.openqa.selenium.By$ByCssSelector.findElement(By.java:430)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:402)
at com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver.findElement(QAFExtendedWebDriver.java:169)
at com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver.findElement(QAFExtendedWebDriver.java:1)
at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:895)
at org.openqa.selenium.support.ui.ExpectedConditions.access$000(ExpectedConditions.java:41)
at org.openqa.selenium.support.ui.ExpectedConditions$6.apply(ExpectedConditions.java:181)
at org.openqa.selenium.support.ui.ExpectedConditions$6.apply(ExpectedConditions.java:178)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:238)

My observation is, it works fine if we don't have driver.findBy(BY) statement. for test purpose in one place i tried driver.findBy(String) instead of driver.findBy(BY) and it worked fine. But i don't know how many places team had used above method.

Below is the test which reproduces error:

@Test
    public void test1() {
        get("/");
        QAFExtendedWebDriver driver = getDriver();
        driver.findElement(By.name("q")).sendKeys("do something");
    }

Because of this issue we have to revert back on selenium version 3.3.1. Can anyone help?


Solution

  • This is because of method visibility change in one of the selenium class. It may get resolved by fix-4279 in next version.

    It is get resolved with qaf-2.1.12-RC2