Closed nicholaswkc34 closed 5 years ago
@peterwkc85 As described in the documentation of the library: https://github.com/AutomatedOwl/chromedriver-js-errors-collector You should store the driver in the JSErrorsDriverHolder object in order for the listener to interact with the driver object.
Can you please try:
@BeforeMethod
void setDriverForListener(Method method) {
// Set your test name to point its ChromeDriver session in HashMap.
JSErrorsDriverHolder.setDriverForTest(method.getName(), driver);
}
@Test(groups= {"Login"}, description="Chrome - Login", priority = 0, dataProvider = "loginCredentials")
@JSErrorsCollectorTestNG(assertJSErrors = false)
public void login(String usernameStr, String passwordStr) {
loginPages = PageFactory.initElements(driver, LoginPages.class);
loginPages.login(visualManager, driver, usernameStr, passwordStr);
}
Let me know about the progress. Regards
Yes, I did expose driver object to JSErrorsCollector class but still facing the issue.
@BeforeSuite
public void setupTest(/*String browser*/ ITestContext context) {
webDriverManager.createDriver("chrome");
driver = webDriverManager.getDriver();
// Set your test name to point its ChromeDriver session in HashMap.
JSErrorsDriverHolder.setDriverForTest(context.getName(), driver);
}
Is there any others solution? Thanks.
@peterwkc85 you should add @BeforeMethod and not @BeforeSuite context.getName() is not returning the test name, which required.
please try:
@BeforeMethod
void setDriverForListener(Method method) {
// Set your test name to point its ChromeDriver session in HashMap.
JSErrorsDriverHolder.setDriverForTest(method.getName(), driver);
}
Yes, it works.
How to get the JS error Report?
Dear All, I’m encounter NULLPointerException when using the library.
Please help on this problem. A billion thanks for your help.