Selenium Certification Training | Anagha | 11th Jan

Discussion in 'Agile and Scrum' started by Support Simplilearn(4685), Jan 10, 2020.

  1. Rashmi_86

    Rashmi_86 Active Member

    Joined:
    Jun 7, 2019
    Messages:
    18
    Likes Received:
    2
    Thank Anagha. yes, I am referring to FB test case and will try to design POM as per your suggestions above
     
    #51
  2. Rashmi_86

    Rashmi_86 Active Member

    Joined:
    Jun 7, 2019
    Messages:
    18
    Likes Received:
    2
    For the samplemaven project that we did in the previous class, Build is successfull and the tests are running fine but
    - I see red mark on samplemaven Project
    - Html folder is not there even though I added dependencies and Listener in POM.xml file, ran Maven Test and Refreshed Target folder

    upload_2020-2-7_20-9-37.png
     

    Attached Files:

    #52
  3. Anagha Gadgil

    Anagha Gadgil Well-Known Member

    Joined:
    Mar 18, 2019
    Messages:
    221
    Likes Received:
    26
    Do a project refresh and see.
    Ensure you have these 2 dependencies for reportNG in your pom.xml
    <dependency>

    <groupId>com.google.inject</groupId>

    <artifactId>guice</artifactId>

    <version>3.0</version>

    <scope>test</scope>

    </dependency>



    <dependency>

    <groupId>org.uncommons</groupId>

    <artifactId>reportng</artifactId>

    <version>1.1.4</version>

    <scope>test</scope>

    </dependency>
     
    #53
  4. Rashmi_86

    Rashmi_86 Active Member

    Joined:
    Jun 7, 2019
    Messages:
    18
    Likes Received:
    2
    Thanks Anagha, I have tried this but I still have the same issue. Probably I am doing some mistake somewhere
     
    #54
  5. Anagha Gadgil

    Anagha Gadgil Well-Known Member

    Joined:
    Mar 18, 2019
    Messages:
    221
    Likes Received:
    26
    send me your pom.xml
     
    #55
  6. Anagha Gadgil

    Anagha Gadgil Well-Known Member

    Joined:
    Mar 18, 2019
    Messages:
    221
    Likes Received:
    26
    what is the maven command you run? Try running mvn clean install
     
    #56
  7. Rashmi_86

    Rashmi_86 Active Member

    Joined:
    Jun 7, 2019
    Messages:
    18
    Likes Received:
    2
    After running Maven Clean and then Maven Install -

    BUILD FAILURE

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile) on project samplemaven: Compilation failure
    [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
     
    #57
  8. Rashmi_86

    Rashmi_86 Active Member

    Joined:
    Jun 7, 2019
    Messages:
    18
    Likes Received:
    2
    POM.xml file has this -

    <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>samplemaven</groupId>
    <artifactId>samplemaven</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>samplemaven</name>
    <url>http://maven.apache.org</url>

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
    <pluginManagement>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M3</version>
    <configuration>
    <SuiteXMLFiles>
    <SuiteXMLFile>testng.xml</SuiteXMLFile>
    </SuiteXMLFiles>
    <property>
    <!-- Setting ReportNG Listeners -->
    <name>listener</name>
    <value>org.uncommons.reportng.HTMLReporter,
    org.uncommons.reportng.JUnitXMLReporter</value>
    </property>
    </configuration>
    </plugin>
    </plugins>
    </pluginManagement>
    </build>

    <dependencies>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.0.0</version>
    <scope>test</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.uncommons/reportng -->
    <dependency>
    <groupId>com.google.inject</groupId>
    <artifactId>guice</artifactId>
    <version>3.0</version>
    <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.uncommons</groupId>
    <artifactId>reportng</artifactId>
    <version>1.1.4</version>
    <scope>test</scope>
    </dependency>
    </dependencies>
    </project>
     
    #58
  9. Anagha Gadgil

    Anagha Gadgil Well-Known Member

    Joined:
    Mar 18, 2019
    Messages:
    221
    Likes Received:
    26
    Ok. For compliler error try this. : Replace your compiler plugin with this one:

    <plugin>
    <artifactId>maven-compiler-plugin</artifactId>

    <configuration>

    <source>1.8</source>

    <target>1.8</target>

    </configuration>

    </plugin>
     
    #59
  10. Anagha Gadgil

    Anagha Gadgil Well-Known Member

    Joined:
    Mar 18, 2019
    Messages:
    221
    Likes Received:
    26
  11. Anagha Gadgil

    Anagha Gadgil Well-Known Member

    Joined:
    Mar 18, 2019
    Messages:
    221
    Likes Received:
    26
    Also update project once. you should not see any red marks on the maven project.
    Right click on the project. ->. Maven. -> update project
     
    #61
  12. J.Bhagyalakshmi

    Alumni

    Joined:
    Jan 6, 2020
    Messages:
    4
    Likes Received:
    0
  13. Rashmi_86

    Rashmi_86 Active Member

    Joined:
    Jun 7, 2019
    Messages:
    18
    Likes Received:
    2
    Hi Anagha, Thanks for helping. Now my project is not marked red and Build is successful. I have removed the compiler plugin from POM.xml file.
    But I still don't see any Html folder in the surefire-Reports folder.
     
    #63
  14. Anagha Gadgil

    Anagha Gadgil Well-Known Member

    Joined:
    Mar 18, 2019
    Messages:
    221
    Likes Received:
    26
  15. Gopal K Maheshwari

    Joined:
    Nov 12, 2019
    Messages:
    4
    Likes Received:
    0
    @Anagha Gadgil , How to use Explicit wait with PageFactory?
    In regular we use "WebElement abc = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("/h1")))" but how to use the same when using Page Factroy @FindBy.
     
    #65
  16. Sowmya S_3

    Sowmya S_3 Customer
    Customer

    Joined:
    Nov 7, 2019
    Messages:
    1
    Likes Received:
    0
    @Anagha Gadgil am not able to return mobileno(integer) values from excell sheet, its returning in 7.866f787 format

    dataprovider code
    @DataProvider
    public Object[][] createdata() throws IOException{
    Object[][] data_set = null;
    HashMap<String, Object> testdata= new HashMap<String, Object>();
    String file=CommonFunctions.readPropertiesFile("excell_path")+CommonFunctions.readPropertiesFile("excell_file_Name");
    String path = System.getProperty("user.dir")+ "/resources";
    String filename = "TestData.xlsx";
    String sheetname = CommonFunctions.readPropertiesFile("sheetNmae");
    inputstream = new FileInputStream(file);

    XSSFWorkbook workbook = new XSSFWorkbook(inputstream);
    Sheet FBSheet = workbook.getSheet(sheetname);

    int rows = FBSheet.getLastRowNum();
    data_set = new Object[3][11];
    for(int row=1; row<=rows; row++) {
    Row rowdata = FBSheet.getRow(row);
    for(int col = 0; col<rowdata.getLastCellNum();col ++) {
    Cell cell_data = rowdata.getCell(col);
    try {
    data_set[row-1][col] = cell_data.getStringCellValue();
    testdata.put(FBSheet.getRow(0).toString(), cell_data.getStringCellValue());
    }catch(Exception e) {
    e.printStackTrace();
    }
    //row-1 to be used to assign the 1st row of data_set
    }//col for loop ends
    }// row for loop ends
    return data_set;
    }
    My csv file:
     

    Attached Files:

    #66
  17. J.Bhagyalakshmi

    Alumni

    Joined:
    Jan 6, 2020
    Messages:
    4
    Likes Received:
    0
    Test post. Please replay it is visible to everyone in the community. Sorry for the inconvenience.
     
    #67
    Last edited: Feb 10, 2020
  18. Rashmi_86

    Rashmi_86 Active Member

    Joined:
    Jun 7, 2019
    Messages:
    18
    Likes Received:
    2
    visible
     
    #68
  19. Anagha Gadgil

    Anagha Gadgil Well-Known Member

    Joined:
    Mar 18, 2019
    Messages:
    221
    Likes Received:
    26

    I checked your excel sheet. The phone no data in your excel sheet itself is wrong. Please change the data first .Also change that column to numeric in excel sheet. Save the excel sheet.

    Now in your code, you can read this particular numeric data using getNumericCellValue. Check the code below and use it appropriately
    if(FBSheet.getRow(row).getCell(2).getCellType() == CellType.NUMERIC) {


    var = (int) FBSheet.getRow(row).getCell(2).getNumericCellValue();

    }
     
    #69
  20. Anagha Gadgil

    Anagha Gadgil Well-Known Member

    Joined:
    Mar 18, 2019
    Messages:
    221
    Likes Received:
    26
    Always use explicit waits on some element which you know need time . And this is the way you can use...

    This is in page class.
    @FindBy(id="email")

    WebElement email;

    public
    void login(String username, String pwd) {

    //To use explicit wait in PageFactory

    WebElement ele_email = new WebDriverWait(driver,10).until(ExpectedConditions.visibilityOf(email));

    ele_email.sendKeys(username);
     
    #70
  21. Rashmi_86

    Rashmi_86 Active Member

    Joined:
    Jun 7, 2019
    Messages:
    18
    Likes Received:
    2
    My code for DataProvider is same as what we did in class. Why am I getting error on this line -
    Sheet FBSheet = workbook.getSheet(sheetname);

    upload_2020-2-11_13-33-24.png


    @DataProvider
    public Object[][] createdata() throws IOException {
    String path = System.getProperty("user.dir") + "/src/EComApp";
    String filename = "valid_Cred.xlsx";
    String sheetname = "valid_Credentials";
    inputstream = new FileInputStream(path + "/" + filename);
    XSSFWorkbook workbook = new XSSFWorkbook(inputstream);
    Sheet FBSheet = workbook.getSheet(sheetname);
    int rows = FBSheet.getLastRowNum();
    System.out.println(rows);
    Object[][] data_set = new Object[3][2];

    for (int row = 1; row <= rows; row++) {
    Row rowdata = FBSheet.getRow(row);
    System.out.println(rowdata.getLastCellNum());
    for (int col = 0; col < rowdata.getLastCellNum(); col++) {
    Cell cell_data = rowdata.getCell(col);
    System.out.println(cell_data);
    data_set[row - 1][col] = cell_data.getStringCellValue();
    // row-1 to be used to assign the 1st row of data_set
    } // col for loop ends
    } // row for loop ends
    return data_set;
    }
     

    Attached Files:

    #71
    Last edited: Feb 11, 2020
  22. Anagha Gadgil

    Anagha Gadgil Well-Known Member

    Joined:
    Mar 18, 2019
    Messages:
    221
    Likes Received:
    26



    Plz check your imported libraries. Everything should be from poi.ss and not from poi.sl
    import java.io.FileInputStream;

    import java.io.FileNotFoundException;

    import java.io.FileOutputStream;

    import java.io.IOException;

    import java.io_OutputStream;



    import org.apache.poi.ss.usermodel.CellType;

    import org.apache.poi.ss.usermodel.Sheet;

    import org.apache.poi.xssf.usermodel.XSSFWorkbook;

    import org.testng.annotations.*;
     
    #72
    Rashmi_86 likes this.
  23. Rashmi_86

    Rashmi_86 Active Member

    Joined:
    Jun 7, 2019
    Messages:
    18
    Likes Received:
    2
    Thanks a lot Anagha for your quick reply! It solved my problem. Somehow, one of my import statements was from poi.sl.
     
    #73
  24. Aparna Mitra

    Aparna Mitra Member

    Joined:
    Sep 10, 2019
    Messages:
    6
    Likes Received:
    2
    Hi Anagha,
    I'm facing similar issues as Rashmi mentioned and screenshared in class. My error msgs are very similar and I cant see the HTML report as well.
     
    #74
  25. Rashmi_86

    Rashmi_86 Active Member

    Joined:
    Jun 7, 2019
    Messages:
    18
    Likes Received:
    2
    I also have not been able to solve that issue yet. If anyone finds a solution, please post here.

    So far I have tried adding maven-surefire-report-plugin in POM.xml file by referring to the following -
    https://stackoverflow.com/questions...g-generated-with-maven-surefire-report-plugin
    https://gist.github.com/dwdking/eface84d904fc4dc2c51015b1d7e1958
    http://maven.apache.org/surefire/maven-surefire-report-plugin/index.html
    http://maven.apache.org/surefire/maven-surefire-report-plugin/usage.html
    https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-report-plugin/3.0.0-M3


    I added these in POM.xml file but it did not solve the issue -

    <reporting>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-report-plugin</artifactId>
    <version>3.0.0-M3</version>
    </plugin>
    </plugins>
    </reporting>

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-report-plugin</artifactId>
    <version>3.0.0-M3</version>
    <executions>
    <execution>
    <phase>test</phase>
    <goals>
    <goal>report</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
     
    #75
  26. Christopher Garrison

    Joined:
    Oct 28, 2019
    Messages:
    10
    Likes Received:
    1
    Hi - I am having same issue with Maven not creating html folder. I tried all steps listed in this thread. I have no red marks next to the project, the html folder is not created in surefire-report. The build is successful, but I noted this error

    upload_2020-2-12_21-27-47.png

    here is my pom.xml code

    <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>SeleniumMaven</groupId>
    <artifactId>samplemaven</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>samplemaven</name>
    <url>http://maven.apache.org</url>

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
    <pluginManagement>
    <plugins>
    <plugin>
    <artifactId>maven-compiler-plugin</artifactId>

    <configuration>

    <source>1.8</source>

    <target>1.8</target>

    </configuration>

    </plugin>
    </plugins>
    </pluginManagement>
    </build>
    <dependencies>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>

    <groupId>com.google.inject</groupId>

    <artifactId>guice</artifactId>

    <version>3.0</version>

    <scope>test</scope>

    </dependency>



    <dependency>

    <groupId>org.uncommons</groupId>

    <artifactId>reportng</artifactId>

    <version>1.1.4</version>

    <scope>test</scope>

    </dependency>

    </dependencies>
    </project>
     
    #76
  27. Aparna Mitra

    Aparna Mitra Member

    Joined:
    Sep 10, 2019
    Messages:
    6
    Likes Received:
    2
    @Rashmi @Christopher - Console outputs are difficult to decode. I receive different maven errors all the time. However, I can see index.html under test-output folder now. And I'm running using Maven Install instead of Maven Test. My pom.xml code as below,

    <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>E2EMavenProject</groupId>
    <artifactId>E2EProjectJan2020</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>E2EProjectJan2020</name>
    <url>http://maven.apache.org</url>
    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
    <pluginManagement>
    <plugins>

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M3</version>
    <configuration>
    <suiteXmlFiles>
    <suiteXmlFile>testng.xml</suiteXmlFile>
    </suiteXmlFiles>
    </configuration>
    </plugin>

    </plugins>
    </pluginManagement>
    </build>
    <dependencies>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.14.3</version>
    <scope>test</scope>
    </dependency>
    </dependencies>

    </project>
     
    #77
  28. Aparna Mitra

    Aparna Mitra Member

    Joined:
    Sep 10, 2019
    Messages:
    6
    Likes Received:
    2
    Hi Anagha,

    I have written the below code as my Utility class for properties File load and I wish to initialize it each time I call it from another class (Eg. LoginPage class) in order to access the values in the properties file.
    Could you please assist as I'm unable to do so.

    Code:

    package com.E2Ep1;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.Properties;
    import org.openqa.selenium.WebDriver;
    public class propertiesUtil {
    // public WebDriver driver;
    public Properties prop;
    public Properties initializeProp() throws IOException {
    prop = new Properties();
    FileInputStream fis = new FileInputStream(
    "E:\\SeleniumAparna\\E2EProjectJan2020\\src\\main\\java\\resources\\data.properties");
    prop.load(fis);

    return prop;
    }
    }
     
    #78
  29. Christopher Garrison

    Joined:
    Oct 28, 2019
    Messages:
    10
    Likes Received:
    1
    @Aparna @Rashi Sinha I am not sure if everyone has already turned in their projects, I asked for a two week extension...There were some posts about an html folder being created in surefire reports. As I work through my project and reflect on the posts, I did not see the correct dependencies or properties for the reports in any posters pom.xml file.

    Maybe everyone figured it out, if not, if you review day 8 notes, and look at the video around 2:30 the solution to running a project as Maven, seeing a ReportNG, and verifying the HTML folder in sure-fire report, is there.

    This is different than the index.html in surefire report folder
     
    #79
    Last edited: Feb 22, 2020
    Rashmi_86 likes this.
  30. Christopher Garrison

    Joined:
    Oct 28, 2019
    Messages:
    10
    Likes Received:
    1
    can anyone help with this error

    package testngtests;

    import org.apache.log4j.Logger;

    public class LoggerUtility {

    private static Logger LoggerUtility = Logger.getLogger(LoggerUtility.class.getName());


    public static void info(String message) {

    LoggerUtility.info(message);

    }

    public static void error(String message) {

    LoggerUtility.error(message);

    }


    }
     
    #80
  31. Rashmi_86

    Rashmi_86 Active Member

    Joined:
    Jun 7, 2019
    Messages:
    18
    Likes Received:
    2
    Hi Christopher,
    I also got some extension for project work. I reviewed day 8 notes and the video but still did not figure out which dependencies and properties are not correct in my pom.xml file. If you got the Html folder in your project can you please share your pom.xml code?
     
    #81

Share This Page