Showing posts with label selenium. Show all posts
Showing posts with label selenium. Show all posts

Wednesday, May 23, 2012

Data providers for selenium

  There are different methods to provide data to selenium tests.

One of these is using the properties file. User can store the data in properties file and use its content for the selenium test

Here is a properties file with some content. Name it as datasuite.properties
     
      Directory = C:/prodFiles/
      NumberOfFiles = 25
      Extension = javaworld


and the corresponding java code to manipulate it


        InputStream is = this.getClass().getResourceAsStream("/conf/datasuite.properties");  
        Properties prop = new Properties();  
        prop.load(is); 
        String directory = prop.getProperty("Directory");  
        String numberOfFiles = prop.getProperty("NumberOfFiles");  
        String  fileExtension = prop.getProperty("Extension");  
        is.close(); 
        
        System.out.println(directory+" "+numberOfFiles+" "+fileExtension);

Below is the folder structure



Friday, October 28, 2011

Selenium test report as mail attachment

Consider a situation where an user wants to mail the reports after all the automation tests have been done. Maven has provided with a plugin maven-postman-plugin.  It is available in the maven repo.

<plugin>
        <groupId>ch.fortysix</groupId>
        <artifactId>maven-postman-plugin</artifactId>
        <configuration>
            <mailhost>smtp.gmail.com</mailhost>
            <mailport>465</mailport>
            <mailssl>true</mailssl>
            <mailAltConfig>true</mailAltConfig>
            <mailuser>xxxx@gmail.com</mailuser>
            <mailpassword>xxxxxxx</mailpassword>
            <from>your_gmail_emailer_account@gmail.com</from>
            <receivers>
                <receiver>receipient@domain.com</receiver>
            </receivers>

            <subject>Important subject</subject>
            <failonerror>true</failonerror>
            <htmlMessage>
                    <![CDATA[
                    <p>Hi,</p>
                    <p>Check out the attached report.</p>
                    ]]>
            </htmlMessage>
            <fileSets>
                <fileSet>
                    <directory>${basedir}/${tests}</directory>
                    <includes>
                        <include>**/emailable-report.html</include>
                    </includes>
                </fileSet>
            </fileSets>
        </configuration>
    </plugin>

The above configuration will send the emailable-report.html as an attachment to all the recipients. If can be configured to send mail at any phase of maven. The following command is used to send mail after the test phase mvn test postman:send-mail.

Will send the mail after the test phase.