0

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);`

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you so much for the clarification, appreciate it!

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.