1

Could someone please let me know if there is any way we can disable the logs generated by the page factory for Chrome and Firefox

I did try the below options for chrome and firefox and I had also turned off the Selenium logs.

Selenium - java.util.logging.Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF);

Chrome - System.setProperty("webdriver.chrome.silentOutput", "true");

Firefox - System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true");
                System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "/dev/null");

But inspite of that these logs are still getting displayed.

Thanks in advance.

enter image description here

Please find below the code:

public class LoginPage {

@FindBy(xpath = "//input[@id='txtUserName']")
WebElement textfield_UserName;
@FindBy(xpath = "//input[@id='txtPassword']")
WebElement textfield_Password;
@FindBy(xpath = "//div/button[@id='btnSave']")
WebElement button_Login;


public LoginPage() {

    super();

}

public void loginPageDisplayed(String userName, String password) throws IOException {

    try {

        if (!status.equalsIgnoreCase("Failed")) {

            PageFactory.initElements(driver, this);
            BasePage.waitUntilElementIsVisible(label_LoginPage);

            BasePage.sendKeysToWebElement(textfield_UserName, userName);
            BasePage.sendKeysToWebElement(textfield_Password, password);

            BasePage.waitAndClickElement(button_Login);

        }

    } catch (Exception e) {

        e.printStackTrace();

    }

}

}

4
  • Can you share some code regarding the PageFactory initiation? It does not print out things be default. Jul 5, 2019 at 14:02
  • @JoãoFarias I have added my code.
    – User1208
    Jul 7, 2019 at 23:20
  • I had put in my Base Page as System.out.println statement. That is why the locators were getting displayed.
    – User1208
    Jul 8, 2019 at 0:52
  • Can you can answer your own questions and accept them as an answer. Unanswered questions keep getting bumped. So please try to either close the question or answer it. Thanks :) Jul 10, 2019 at 9:23

1 Answer 1

0

PageFactory does not print out selectors by default. So it is probably something you added yourself in the base class.

A good way to research this is to use step-by-step debugging in your IDE. Set a breakpoint where you use the selector. Run the tests in debug-mode and from then use the step in option to see what code is being executed. Eventually you should run into a line of code that prints the selector.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.