webdriver - java.lang.ClassCastException: com.sun.proxy.$Proxy8 cannot be cast to org.openqa.selenium.internal.WrapsDriver -
i have following pointcut , given advice in aspectj
@pointcut("(call(* org.openqa.selenium.webelement.sendkeys(..)))") public void onwebelementaction() { } @after("onwebelementaction() && target(webelement)") public void afterwebelementaction(joinpoint joinpoint, webelement webelement) { system.out.println(webelement.getattribute("name")); //1 webdriver driver = ((wrapsdriver) webelement).getwrappeddriver(); //2 //do here }
while line 1 executed without error. on line 2 error
java.lang.classcastexception: com.sun.proxy.$proxy8 cannot cast org.openqa.selenium.internal.wrapsdriver
the casting works in other places without issues. can please help?
this wild guess since don't see case worked. exception seems webelement being passed afterwebelementaction
initialized via pagefactory
. guess if pass webelement derived driver.findelement(), afterwebelementaction
, wouldn't casting exception. how must working in other cases likely.
Comments
Post a Comment