简体   繁体   English

控制台输出Selenium Webdriver

[英]Console Output Selenium Webdriver

Every single time I run my test case, some of the put is spaced out while others are connected, why is that and what's the fix? 每当我运行测试用例时,其中一些放置就被间隔开了,而另一些则被连接了,这是为什么?解决方法是什么? Here's a sample code and a picture of console output Console output results ` 这是示例代码和控制台输出的图片控制台输出结果

        if(driver.getPageSource().contains("Create Report"))
        {

            System.out.println("   Test Case 2a Report Page Create Report Field Passed");
        }
        else{

            System.out.println("   Test Case 2a Report Page Create Report Field Failed");
        }
    Thread.sleep(3000);

    // Quick Reports
    // Ensure the dates are visible

        if(driver.getPageSource().contains("Quick Reports"))
        {

            System.out.println("   Test Case 2b Report Page Quick Reports Field Passed");
        }
        else{

            System.out.println("   Test Case 2b Report Page Quick Reports Field Failed");
        }
    Thread.sleep(3000);

    // Last Week
    // Ensure Last Week Link Text is present


        boolean isDisplayed1 = driver.findElement(By.xpath(".//*[@id='block-2']/div/table/tbody/tr/td[2]/div[1]/div/div[2]/div[1]/a")).isDisplayed();

        if (isDisplayed1) {
            System.out.print("   Test Case 2c Last Week Link Text Present");
        }else{
            System.out.print("   Test Case 2c Last Week Link Text not Present");
        }

    Thread.sleep(2000);

    // Last Month 
    // Ensure Last month link text present

        boolean isDisplayed2 = driver.findElement(By.xpath(".//*[@id='block-2']/div/table/tbody/tr/td[2]/div[1]/div/div[2]/div[3]/a")).isDisplayed();

        if (isDisplayed2) {
            System.out.print("   Test Case 2d Last Month Link Text Present");
        }else{
            System.out.print("   Test Case 2d Last Month Link Text not Present");
        }

    Thread.sleep(3000);

    // Year to Date
    // Ensure Year to Date Link Text is present

        boolean isDisplayed3 = driver.findElement(By.xpath(".//*[@id='block-2']/div/table/tbody/tr/td[2]/div[1]/div/div[2]/div[5]/a")).isDisplayed();

        if (isDisplayed3) {
            System.out.print("   Test Case 2e Year to Date Link Text Present");
        }else{
            System.out.print("   Test Case 2e Last Year tp Date Link Text not Present");
        }

    Thread.sleep(3000);`

If i understand correctly, you are asking why some output is printed on new line, while other isn't. 如果我理解正确,您是在问为什么一些输出打印在新行上,而其他输出却不是。

That's because in some places you use 那是因为您在某些地方使用

System.out.println

which prints a string and moves the cursor to new line. 打印一个字符串并将光标移到新行。 And sometimes you use 有时候你用

System.out.print

which prints a string and does not move the cursor to new line. 它会打印一个字符串, 并且不会将光标移到新行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Selenium WebDriver获取Firebug控制台输出 - Get Firebug console output using Selenium WebDriver 从Selenium WebDriver删除控制台日志 - Remove console logs from selenium webdriver 如何在硒webdriver中拆分输出并仅打印部分输出? - how to Split output and print only a part of output in selenium webdriver? 如何使用带有Java的Selenium WebDriver将命令写入Firefox控制台? - How to write commands into the Firefox console using Selenium WebDriver with Java? 如何使用Selenium WebDriver + Java获取浏览器控制台错误消息? - How to get browser console error messages using Selenium WebDriver + Java? 如何使用 JAVA 在 Selenium WebDriver 中打开 Chrome 开发者控制台 - How to open Chrome Developer console in Selenium WebDriver using JAVA Selenium Webdriver:禁止在控制台上打印 IE 日志信息 - Selenium Webdriver : Suppress IE log info prints on the console Java Selenium WebDriver-如何输出JavaScript对象的属性? - java selenium webdriver - how to output the attribute of a javascript object? 从输出Excel读取数据时,它显示Selenium Webdriver中的错误 - While reading the data from output excel,it shows error in selenium webdriver 我不明白 selenium webdriver java 产生的这个输出 - I dont understand this output produced by selenium webdriver java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM