I am trying to plug in js element highlighting to selenium framework. I have this code:
@Aspect
public class HighlightAspect {
@Pointcut("execution(* *.click())")
private void allClickMethods(){}
@Before("allClickMethods()")
public void proxyClick(ProceedingJoinPoint joinPoint){
WebElement element = (WebElement)joinPoint.getTarget();
highlight(element, "green");
}
private void highlight(WebElement element, String color) {
Browser.getBrowser().executeScript("arguments[0].style.backgroundColor = '"+color+"'", element);
}
}
I initialize spring context in 'main' class like:
private static ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("spring_config.xml");
And my src/main/resources/spring_config.xml
looks like:
<aop:aspectj-autoproxy />
...
<bean
id="highlightAspect"
class="com.<my_name_space>.HighlightAspect">
</bean>
...
I don't receive any exceptions from JVM, but when I add a logger to proxyClick
I see this method didn't happen to be executed.
Please, help me to make it work.