How to mavenize a java project from Selenium Webdriver

29 views
Skip to first unread message

ama...@bufetedemarketing.com

unread,
Jun 20, 2017, 7:01:04 AM6/20/17
to Selenium Users
Hi guys!

I'm trying to mavenize a group of java projects made in Selenium Webdriver.

I've achieved to mavenize a little test, but, now, I need to mavenize a group of tests.

My "pom.xml" file contains the following:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>SeleniumProject</groupId>
  <artifactId>SeleniumProject</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  <dependencies>
        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <version>4.12</version>
             <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.4.0</version>
</dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.11</version>
            <scope>test</scope>   
        </dependency>
       
        <dependency>
       <groupId>org.apache.poi</groupId>
       <artifactId>poi</artifactId>
       <version>3.10.1</version>
     </dependency>
 </dependencies>
  
  <build>
    <sourceDirectory>src</sourceDirectory>
    
    <plugins>
    
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      
      <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<source>2.19.1</source>
<target>2.19.1</target>
</configuration>
  </plugin>
      
    </plugins>
  
  </build>

</project> 

The structure of the little test is the following (it works well):

package example;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

public class NewTest {
   private WebDriver driver;
   
@Test
public void testEasy() {
String title = driver.getTitle();  
Assert.assertTrue(title.contains("Demo Guru99 Page"));
}
@BeforeTest
public void beforeTest() {
System.setProperty("webdriver.gecko.driver","C:\\Users\\amartin\\Downloads\\geckodriver-v0.17.0\\geckodriver.exe");
   DesiredCapabilities capabilities = DesiredCapabilities.firefox();
   capabilities.setCapability("marionette", true);
   driver = new FirefoxDriver(capabilities);
   
}
@AfterTest
public void afterTest() {
driver.quit();
}
}

But now, with a lot of java files, I don't know how to match them in an only TestNG Class.

I've searching in several web pages but I don't understand at all.

Could you tell me any tutorial to do that?

Thanks so much for your help!


ama...@bufetedemarketing.com

unread,
Jun 21, 2017, 2:52:50 AM6/21/17
to Selenium Users
Any ideas??
Thanks!!!

ama...@bufetedemarketing.com

unread,
Jun 21, 2017, 3:38:49 AM6/21/17
to Selenium Users
I've tried to follow the page: http://wiki.eclipse.org/Converting_Eclipse_Java_Project_to_Maven_Project
but I try to install Apache Maven (IAM)plugin, and I get the following error:


How could I solve it? I don't find a solution.

Otherwise, I've tried to Convert to Maven Project, but I don't get anything to execute in TestNG. I show you the steps:


Pom.xml appears:



I don't get any TestNG.xml to execute, every files are still in the same way:



How have I to continue? or start? :(

Thanks so much...!!!



El martes, 20 de junio de 2017, 13:01:04 (UTC+2), ama...@bufetedemarketing.com escribió:

ama...@bufetedemarketing.com

unread,
Jun 21, 2017, 3:43:20 AM6/21/17
to Selenium Users
I've created a TestNG Class with my java package but I don't get any commands inside the new file:

Have I written every code in that new file??? 

Thanks so much...!


El martes, 20 de junio de 2017, 13:01:04 (UTC+2), ama...@bufetedemarketing.com escribió:
Reply all
Reply to author
Forward
0 new messages