Do you have questions ? We got the answers!

Ask a question:

0
java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebDriver cannot be cast to TakesScreenshot

Solved 1 Answers 61 Views
I am getting below error while taking a screenshot.

java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebDriver cannot be cast to org.openqa.selenium.TakesScreenshot

    at com.qamate.pages.HomePage.takeScreenShot(HomePage.java:73)
    at com.qamate.pages.HomePage.SelectADepartment(HomePage.java:67)
    at com.qamate.step_definations.CheckoutStepDefinitions.addProductsToShoppingBag(CheckoutStepDefinitions.java:60)
    at ✽.Given User added products to shopping bag(com/qamate/checkout.feature:8)

 

What is the possible solution?

1 Answer

1
Best answer

There are two things suggest you.

1. Update your selenium dependency to 3.4.0 or the latest one.

And

2. Instead of casting your RemoteWebDriver instance directly, you should use Augmenter as given below.

WebDriver augmentedDriver= new Augmenter().augment(driver);
File screenShot = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);

 

answered May 13 by monisha (51 points)
selected May 14 by stbadmin

Top Contributors

  • 4970 pointsstbadmin

    34 questions 454 answers218 comments

  • 433 pointsSunilBhaskar

    41 questions 15 answers32 comments

  • 425 pointsMehedi

    36 questions 3 answers14 comments

  • 364 pointssumitkumarwatts

    0 questions 14 answers0 comments

  • 354 pointsSoft Tester

    43 questions 0 answers4 comments

  • 327 pointsKeeshaGolden

    0 questions 17 answers2 comments

  • 322 pointsVipul Sharma

    44 questions 0 answers24 comments

  • 310 pointsvysh.sharma

    25 questions 0 answers0 comments

  • 267 pointsOnkar_Nimje

    33 questions 15 answers15 comments

  • 258 pointsVanitha

    26 questions 0 answers6 comments

...