Saturday, April 16, 2022

How to run tests in TestNg.xml using Maven

 Add the below code snippet inside pom.xml file

<build>
 <!-- Source directory configuration -->
       <sourceDirectory>src</sourceDirectory>
       <plugins>
           <!-- Following plugin executes the testng tests -->
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-surefire-plugin</artifactId>
               <version>2.19.1</version>
               <configuration>
       <!-- Suite testng xml file to consider for test execution -->
                   <suiteXmlFiles>
                       <suiteXmlFile>testng.xml</suiteXmlFile>
                   </suiteXmlFiles>
               </configuration>
           </plugin>
 <!-- Compiler plugin configures the java version to be used for compiling the code -->
           <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                   <source>1.8</source>
                   <target>1.8</target>
               </configuration>
           </plugin>
       </plugins>
 </build>

Now run from project root in command prompt or terminal

>mvn clean install

Saturday, January 15, 2022

How to use JavaScript in Google chrome Console?

In this tutorial we will write simple JavaScript on Google chrome console to get all the elements text inside ul li tags from below HTML code.

HTML Code:

<ul class="multiselect-container dropdown-menu">
<li class="multiselect-item multiselect-all">
<a tabindex="0" class="multiselect-all">
<label class="checkbox">
<input type="checkbox" value="multiselect-all"
class="regular-checkbox"> Select all</label>
</a>
</li>
<li class="">
<a tabindex="0"><label class="checkbox">
<input type="checkbox" value="CANCELLED"
class="regular-checkbox"> Cancelled</label>
</a>
</li>
<li class="">
<a tabindex="0"><label class="checkbox">
<input type="checkbox" value="CONFIRMED"
class="regular-checkbox"> Confirmed</label></a></li>
<li class="">
<a tabindex="0"><label class="checkbox">
<input type="checkbox" value="REJECTED"
class="regular-checkbox"> Rejected</label>
</a>
</li>
</ul>

 

SOLUTION:

 [
    ...new Set(
        $x("//ul[@class='multiselect-container dropdown-menu']//a/label")
            .map(value=> (
                value.textContent
             )

         )

    )

]

ANSWER:

(4) [' Select all', ' Cancelled', ' Confirmed', ' Rejected']

Read CSV from S3

 import csv def count_records(csv_file):     record_count = 0     first_line = None     last_line = None     # Open the CSV file and read it...