While trying get the color of the dot from web page I am getting error

34 Views Asked by At

The Error I am getting is Below: org.openqa.selenium.JavascriptException:javascript error:Failed to execute'getComputedStyle' on 'Window': parameter 1 is not of type 'Element' I am trying to find the element and get the color of it and the element is stored in DOM with ::before I am not getting this element color by using xpath for span please suggest what wrong with this code

String script = "return window.getComputedStyle(document.querySelector('.dot[_ngcontentephc8]'),':before').getPropertyValue('background')";
JavascriptExecutor jse = (JavascriptExecutor)Browser.getDriver();
String colorCode = (String) jse.executeScript(script);
System.out.println("colorCode);
String hexColorCode = convertBackgroundColorToHexFormat(colorCode);
System.out.println("hexColorCode);
return hexColorCode.equalsIgnoreCase(color);
0

There are 0 best solutions below