How to obtain native logger in Selenium WebDriver

后端 未结 4 1570
悲&欢浪女
悲&欢浪女 2020-12-02 15:49

Is it possible to obtain the logger somehow that Selenium WebDriver uses? I want to capture a transcript of all the commands that were issued (eg: open, wait, click, etc). I

4条回答
  •  青春惊慌失措
    2020-12-02 16:37

    I'm using log4j for logging as utils logger is the most easiest and straight forward one that, that can be used (IMHO).

    POM dependencies:

    
               org.apache.cassandra
              cassandra-all
              0.8.1
          
    
          
              org.slf4j
              slf4j-api
              1.6.6
          
          
              org.slf4j
              jcl-over-slf4j
              1.6.6
              runtime
          
          
              org.slf4j
              jul-to-slf4j
              1.6.6
              runtime
          
          
              org.slf4j
              log4j-over-slf4j
              1.6.6
              runtime
          
    

    imports are following:

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    

    usage:

    private static Logger log = LoggerFactory.getLogger(classname.class);
    

    and then just use it as such:

    logger.info ("butonCLick");
    driver.findElement(By.id("blablabla")).click();
    

    Hope this works for you.

提交回复
热议问题