Re: Running multiplay test with junit and TAURUS

613 views
Skip to first unread message
Message has been deleted

pri...@blazemeter.com

unread,
Aug 30, 2016, 4:41:49 AM8/30/16
to codename-taurus, stanislav...@gmail.com
Hi,

When executing Selenium tests, Taurus measures execution time for each test case (method with @Test annotation). So you can split your 10 pages into 10 tests, and Taurus will treat them as different requests (labeled by test method name). Then you can either use BlazeMeter reporting or set up a final stats reporter to dump loading times for all pages to CSV/XML.

Give it a try, and ping us if you have any questions or issues.


  Dmitri

On Monday, August 29, 2016 at 11:45:25 AM UTC+3, stanislav...@gmail.com wrote:
Hi Taurus support team,

my name is Stanislav. at the work i have a task to measure page load time. The project is with login page(session). The question is: How can i perform page load test for specific page when i have login form. Below is the example of my code.
Or when i have big dependent test and i test i have 10 different pages and some pages contain attachment files, how is possible to tell the test that i want to measure page load time of different pages? Will wait for your answer.


11:30:47 INFO: Average times: total 6.490, latency 0.000, connect 0.000
11:30:47 INFO: Percentile 0.0%: 6.490
11:30:47 INFO: Percentile 50.0%: 6.490
11:30:47 INFO: Percentile 90.0%: 6.490
11:30:47 INFO: Percentile 95.0%: 6.490
11:30:47 INFO: Percentile 99.0%: 6.490
11:30:47 INFO: Percentile 99.9%: 6.490
11:30:47 INFO: Percentile 100.0%: 6.490

TEST.yml
---
execution:
- executor: selenium
  scenario: simple
  concurrency: 1

scenarios:
 simple:
  requests:
  - http://10.32.1.114:9080
  method: GET
  script: /home/xxxxx/Desktop/XXXXX/src/test/java/Testing_2.java
  additional-classpath: ~/.bzt/jmeter-taurus/lib/selenium-java-2.53.1.jar
 
modules:
 selenium:
  selenium-tools:
   junit:
    path: ~/.bzt/jmeter-taurus/lib/junit-4.12.jar
    compile-target-java: 1.7
    hamcrest-core: ~/.bzt/jmeter-taurus/lib/hamcrest-core-1.3.jar
 
cli-aliases:
  report:
   reporting:
   - blazemeter


Testing_2.java
*****************************************************************''
WebDriver driver = new FirefoxDriver();

@Before
public void setup() {
driver.navigate().to("http://10.111.111.114:9080");
}

@Test
public void login() throws InterruptedException {
WebDriverWait wait = new WebDriverWait(driver, 60);

driver.findElement(By.cssSelector("a[ng-click='vm.closeTokenForm()']")).click();

driver.findElement(By.cssSelector("div[class='text-center']")).getText();

driver.findElement(By.linkText(user)).click();

Thread.sleep(2000);

WebElement table = driver.findElement(By.cssSelector("table[class='large-12 columns ng-scope']"));
java.util.List<WebElement> tr_collection = table.findElements(By.cssSelector("tbody > tr"));
wait.until(ExpectedConditions.visibilityOfAllElements(tr_collection)).size();
}

@After
public void close() {
driver.close();
}



Message has been deleted
Message has been deleted

Dmitri Pribysh

unread,
Aug 30, 2016, 7:39:01 AM8/30/16
to stanislav...@gmail.com, codename-taurus
To fix the order of test execution, i can suggest postfixing method names with two digits instead of one (i.e. test_01, test_02, ..., test_10, test_11), so sorting in JUnit won't mess up the order. OR you can try to refactor your tests a little bit, so they're order-independent.

About jar: you should use `additional-classpath` if your test script depends on a certain jar. `jar-name` is mostly an internal Taurus option.


On 08/30/2016 01:53 PM, stanislav...@gmail.com wrote:
ok i have tried your solution. I had one big test with one @Test annotation, now i have them 11. In TESTNG is test priority simple just write priority = 1; =2 etc, but in junit this is not supported. I have put in beginning of the class
@FixMethodOrder(MethodSorters.NAME_ASCENDING) an give for test method names test1(), test2(), test3() etc. and the result in intellij is: test1(), test10, test11, test2, test3 .... . Example of my code is below:

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Taurus {

    DetectOs detectOs = new DetectOs();
    private String ametnik = "xxxx";
    String webPage = "http://xx.xxx.xx.xx.x:xxx";
    TryOrCatch tryOrCatch = new TryOrCatch();
    Nupud nupp = new Nupud();
    Screencapture screencapture = new Screencapture();

    @Before
    public void before(){
        detectOs.firefox();
    }

    @Test
    public void test1() throws Exception {
        Sisselogimine login = new Sisselogimine();
        login.privateLogin(detectOs.getDriver(), webPage, ametnik);
    }

    @Test
    public void test2() throws InterruptedException {
        IsikuOtsing isikuOtsingMenu = new IsikuOtsing();
        String isikukood = "xxxxxxxxxxx";
        Thread.sleep(10000);
        isikuOtsingMenu.iskuOtsing(detectOs.getDriver(), isikukood);

    }

    @Test
    public void test3() {
        IsikuOtsing valimine = new IsikuOtsing();
        valimine.isikuValimine(detectOs.getDriver());

    }

    @Test
    public void test4() throws InterruptedException {
        System.out.println(detectOs.getDriver().findElement(By.cssSelector("h1[class='b-title__heading ng-scope']")).getText() + " on avatud");
        Thread.sleep(5000);

    }

    @Test
    public void test5() throws InterruptedException, IOException {
        tryOrCatch.tryCatch(detectOs.getDriver());
        screencapture.screencapture(detectOs.getDriver());
        nupp.edasi(detectOs.getDriver());

    }

    @Test
    public void test6() throws InterruptedException, IOException  {
        tryOrCatch.tryCatch(detectOs.getDriver());
        screencapture.screencapture(detectOs.getDriver());
        MaarusedAndmed maaruseAndmed = new MaarusedAndmed();
        maaruseAndmed.maaruseAndmed(detectOs.getDriver());

    }

    @Test
    public void test7() throws InterruptedException, IOException  {
        tryOrCatch.tryCatch(detectOs.getDriver());
        screencapture.screencapture(detectOs.getDriver());
        WebElement checkbox = detectOs.getDriver().findElements(By.cssSelector("input[ng-model='laps.valitud']")).get(0);

        if (!checkbox.isSelected()) {
            checkbox.click();
        }
        nupp.edasi(detectOs.getDriver());

    }

    @Test
    public void test8() throws InterruptedException, IOException {
        tryOrCatch.tryCatch(detectOs.getDriver());
        screencapture.screencapture(detectOs.getDriver());
        nupp.edasi(detectOs.getDriver());
    }

    @Test
    public void test9() throws InterruptedException, IOException {
        tryOrCatch.tryCatch(detectOs.getDriver());
        screencapture.screencapture(detectOs.getDriver());
        ValjamaksedJaTeavitus valjamaksedJaTeavitus = new ValjamaksedJaTeavitus();
        valjamaksedJaTeavitus.valjamakseJaTeavitus(detectOs.getDriver());

    }

    @Test
    public void test10() throws InterruptedException, IOException {
        tryOrCatch.tryCatch(detectOs.getDriver());
        screencapture.screencapture(detectOs.getDriver());
        nupp.edasi(detectOs.getDriver());
    }

    @Test
    public void test11() throws InterruptedException, IOException {
        tryOrCatch.tryCatch(detectOs.getDriver());
        screencapture.screencapture(detectOs.getDriver());
        Eelvaade eelvaade = new Eelvaade();
        eelvaade.eelvaade(detectOs.getDriver());

    }

    @After
    public void close() {
        detectOs.getDriver().close();
    }
}

and one more question. i have packet my project to .jar file. in yml. i need to add this file in modules using jar-name: or in screnatios using additional-classpath?

Will wait for your answer.
-- You received this message because you are subscribed to the Google Groups "codename-taurus" group. To unsubscribe from this group and stop receiving emails from it, send an email to codename-taur...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/codename-taurus/5050803a-e0b1-486a-b27d-cc93c39b630e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Dmitri Pribysh

unread,
Aug 30, 2016, 8:31:00 AM8/30/16
to Stanislav Tsvetajev, codename-taurus

This indicates that Java compiler didn't recognize your jar from additional classpath.

Try to put a full path to your jar in `additional-classpath` (i.e. /home/user/src/project.jar).


On 08/30/2016 03:24 PM, Stanislav Tsvetajev wrote:
ok, the priority is working. My test has many other test classes that are in different packets(folders). When i run bzt test.yml it gives me error: Picture in attachment.


-- You received this message because you are subscribed to the Google Groups "codename-taurus" group. To unsubscribe from this group and stop receiving emails from it, send an email to codename-taurus+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/codename-taurus/5050803a-e0b1-486a-b27d-cc93c39b630e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Dmitri Pribysh

unread,
Aug 30, 2016, 9:32:20 AM8/30/16
to Stanislav Tsvetajev, codename-taurus

Oh, so your tests are already bundled in a jar? Then you can specify this jar as a `script` in scenario, and do not specify it in`additional-classpath`.


On 08/30/2016 03:47 PM, Stanislav Tsvetajev wrote:
i understand what this means :). and the classpath is fine. in attachment i have added two pictures, one for .yml and other .jar extract.
Message has been deleted

pri...@blazemeter.com

unread,
Aug 30, 2016, 10:16:36 AM8/30/16
to codename-taurus, stanislav...@gmail.com
Have you tried to specify your jar as a `script` inside scenario, i.e.
---
execution:
- scenario: test
  iterations: 1
  script: your.jar



On Tuesday, August 30, 2016 at 5:12:13 PM UTC+3, stanislav...@gmail.com wrote:

When i go to the log folder -> classes -> i dont see there complied.jar file, only Taurus.java. My mistake in configuration? have deleted old configuration ~/.bzt folder and made upgrade for bzt to 863 version. Had hamcrest issue but now its gone. Will wait for your answer what to do next
Message has been deleted
Message has been deleted

pri...@blazemeter.com

unread,
Sep 1, 2016, 6:15:43 AM9/1/16
to codename-taurus, stanislav...@gmail.com
This shouldn't give the same error, because `javac` isn't invoked when jar is specified as a script. What error did you get?

On Wednesday, August 31, 2016 at 11:50:52 AM UTC+3, stanislav...@gmail.com wrote:
Hi,

i have tried and same error!

regards,
Message has been deleted
Message has been deleted

bushne...@gmail.com

unread,
Sep 8, 2016, 5:27:06 AM9/8/16
to codename-taurus, stanislav...@gmail.com
Hi.

I'm not sure, but for me relative path from home dir via "~/.." didn't work. But worked when I have changed it to full path. 
Try the same with the full path just to eliminate that it is not the cause.


On Thursday, September 1, 2016 at 4:16:29 PM UTC+3, stanislav...@gmail.com wrote:
Hi,

16:11:03 ERROR: RuntimeError: Javac exited with error:
 warning: [options] bootstrap class path not set in conjunction with -source 1.7.

Have tried to put the jar file in additional-classpath and execution section getting same error. have tried also to remove complie-target-java and same. Tried with different java versions .17, 1.8. SAME. Maybe i am doing something wrong?
conf:

---
execution:
- executor: selenium
  scenario: TEST
  iterations: 1
  script: ~/IdeaProject/Skais2/SKAIS2_SeleniumTests/target/selenium-1.0-SNAPSHOT-tests.jar  

scenarios:
 TEST:
  requests:
  method: GET
  script: ~/IdeaProject/Skais2/SKAIS2_SeleniumTests/src/test/java/Taurus.java
  additional-classpath: ~/.bzt/jmeter-taurus/lib/selenium-java-2.53.1.jar

modules:
 selenium:
  selenium-toolks:
   junit:
    complie-target-java: 1.8


cli-aliases:
  report:
   reporting:
   - blazemeter
   - module: junit-xml
   - module: final_stats


regards,
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages