Selenium perform task to the end

Asked

Viewed 180 times

1

In tests with Selenium, running by Eclipse, when I run several at the same time. Errors happen:

  • First, does not finish running the task opens another browser.
  • Starts running the second test without even having finished the first
  • Problem as it is with the same user, and a user can only have one session so
  • When the first test is finished, the system has already invalidated the session.
  • Failing the test you didn’t even run because you missed the session.

I tried many settings already so that it runs as follows. Only one thread and all the way, but I was unsuccessful.

Two reasons for these tests to be so, are integration tests validate very complex scenarios simulate a user doing sequential operations within the system.

How I reach that goal. 1 - Thread at a time running the task until the end, then go to the next so until you get to the last test

  • Save! Already solved? Can you post your configuration? You are using the Maven plugin (failsafe)?

  • I posted how I solved, but I wanted it to be just with Annotation, but in these versions Selenium has many unresolved problems regarding this

  • And there he comments on the answer of right, it was useful. when it goes right there put as it did.

1 answer

0

I made several configurations with Annotations, they even work a few times but they present a very big instability.

So I was able to understand that only with Annotations does not work, Selenium problems when generating the xml to run the tests and configures the thread pool to run the tests.

So solved like this: You have 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
  • Marcelo, I don’t use NG so I won’t dare give you an incorrect direction. What I suggest is that you use Failsafe to run your tests. It is made to run in the context of integration tests, which seems to be your case. The first thing to do is to separate the unit and integration tests. Take a look at this example: http://maven.apache.org/surefire/maven-failsafe-plugin/examples/testng.html. Tap if you have problems.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.