Selenium run task to the end

1

In tests with Selenium, running through Eclipse, when I run several at the same time. The errors happen:

  • First, do not finish running the task open another browser.
  • Begins to run the second test without even finishing the first
  • Problem as it is with the same user, and a user can only have one session then
  • When the first test is completed again, the system has already invalidated the session.
  • Failing the test that you did not even execute because you missed the session.

I've tried many settings already so that it runs as follows. Only a thread and to the end , but I did not succeed.

Two reasons for these tests to be so are integration tests validate many complex scenarios that simulate a user doing the operations sequences within the system.

How do I reach this goal. 1 - Thread per time running the task until end, then goes to the next so until you reach the last test

    
asked by anonymous 25.10.2016 / 18:42

1 answer

0

I made several configurations with annotations, they even work a few times but they show a great instability.

Then I managed to understand that only with annotations does not work, Selenium problems in generating the xml to run the tests and configures the thread pool to run the tests.

Then solved like this: Has the ngtest plugin and file configuration

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <properties>
            <propertie>
                <name>junit</name>
                <name>false</name>
            </propertie>
        </properties>
        <threadCount>1</threadCount>
        <useUnlimitedThreads>true</useUnlimitedThreads>
        <suiteXmlFiles>
            <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
        </suiteXmlFiles>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-junit47</artifactId>
            <version>2.19.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-testng</artifactId>
            <version>2.19.1</version>
        </dependency>
    </dependencies>
</plugin>

//arquivo de confugaração src/test/resources/testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none" preserve-order="true" thread-count="1"  >
    <test name="Test" parallel="none" preserve-order="true" thread-count="1" >
        <classes>
            <class name="com.SuaClasse_de_teste_PrimeiraTest" />
            <class name="com.SuaClasse_de_teste_SegundaTest" />
            <class name="com.SuaClasse_de_teste_E_assim_por_conforme_sua_necessidade_de teste_Test" />
            <class name="com.SuaClasse_de_teste_Test" />
        </classes>
    </test> <!-- Test -->
</suite> <!-- Suite -->
//veja o nome das classes ajuda a enteder o contexto
    
25.10.2016 / 20:05