Resolving the Git Error current-branch-is-not-configured-for-pull



Resolution for the Error ->Current Branch is not configured for Pull. No Value for key remote.origin.url found in configuration.
In Github , during the creation of branch we should make sure to select the option configure upstream for push and pull. What happens if this option is not selected?? This causes the “git pull” operation causing the error. In this post we are going to discuss on now fixing the error in Eclipse as follows:

onfigure upstream for push and pull

configure upstream for push and pull


Right Click on the project in Eclipse->Team->Git Pull throws the following Error:

Pulling 1 repository The current branch is not configured for pull No value for key remote.origin.url found in configuration

Pulling 1 repository
The current branch is not configured for pull
No value for key remote.origin.url found in configuration


How do we resolve this Error now???
Navigate to the Eclipse Menu->Window->Show View->Other->Git Repositories.
GitRepositories

GitRepositories


Update the Config File in the Repository as mentioned below:
[branch "PullRequestError"]     remote = origin 	merge = refs/heads/PullRequestError

[branch “PullRequestError”]
remote = origin
merge = refs/heads/PullRequestError


What is the statement **refs/heads/PullRequestError** in the config file refer to ??

The ref in the URL must be formatted as heads/<branch name> for branches and tags/<tag name> for tags. If the ref doesn’t exist in the repository, but existing refs start with ref they will be returned as an array. If the ref doesn’t match an existing ref or any prefixes, a 404 is returned.

Running suite-of-suites Parallely in Testng




TestNG is a java framework useful to execute the Unit Tests in a java project. We can even TestNG to automate the Selenium Tests in the Project.In TestNG xml file, the execution of Tests is managed by setting the “parallel” attribute and “thread-count” attribute in the suite xml as follows:

  • <suite name=”My suite” parallel=”methods” thread-count=”5″>
  • <suite name=”My suite” parallel=”tests” thread-count=”5″>
  • <suite name=”My suite” parallel=”classes” thread-count=”5″>
  • <suite name=”My suite” parallel=”instances” thread-count=”5″>
  • Now the question arises that how can we execute multiple Testng xml files in the project. The solution is as follows:

    <suite name=”Running Suite Files” verbose=”1″ preserve-order=”true”>
            <listeners>
                    <listener class-name=”org.testng.reporters.VerboseReporter”/>
            </listeners>
            <suite-files>
                    <suite-file path=”testng1.xml”/>
                    <suite-file path=”testng2.xml”/>
            </suite-files>

    </suite>


    How do we execute these suite-of-suite files parallely?

    Conclusion::


    Execution of the ParallelSuites.java program, stores the Results in the output folder.Make sure the Project is refreshed to view the results as mentioned below:

    is-there-a-possible-way-to-run-two-xml-files-in-testng-xml-parallel

    is-there-a-possible-way-to-run-two-xml-files-in-testng-xml-parallel



    Passing command line arguments for Selenium Maven Testng



    TestNG allows you to group your tests and also allows to pass Test Parameters using parameter tag in the TestNG xml file.
    You can then execute one or more specific groups such as Sanity,Regression or Functional Tests based on the requirement and passing the parameter values to the testng.xml using maven-surefire-plugin via pom.xml the following configuration is helpful.

    Passing the specific group name from the Command Line is achieved by updating the configuration of maven-sure-fire plugin as follows:

    Maven Command Line:

    Maven Command Line Arguments-Selenium,TESTNG

    Maven Command Line Arguments-Selenium,TESTNG

    Steps to achieve is mentioned as follows:

    Like our Facebook Page to stay in touch with us. Happy Testing!!!!
    https://www.facebook.com/totalqa

    1. Create a Testng @Test program as follows.

    2. Create an Grouping.xml file to invoke the Testng @Test Program.

    3. Update the pom.xml as follows.

    4. Download the apache maven software apache-maven-3.6.0-bin.tar.gz from this url https://maven.apache.org/download.cgi.

    5. Set the classpath as follows.

    Apache Maven Software Classpath

    Apache Maven Software Classpath

    6. Execute the following command from the command line.

    Maven Command Line Arguments-Selenium,TESTNG

    Maven Command Line Arguments-Selenium,TESTNG

    Conclusion:

    Passing the command line arguments is possible by using apache maven via pom.xml to the TestNG.xml

    Headless Browser in Selenium using PhantomJS-Pros and Cons



    PhantomJS is a headless web browser scriptable with JavaScript which is similar to HTMLUnitDriver. Click on this link to view the examples of the HTMLUnitDriver.

    PhantomJS runs on Windows, macOS, Linux, and FreeBSD. Currently the PhantomJS development is stopped due to less support from the group.

    Pros of Headless Browser:

    • Headless browser executes the scripts faster then the real browser.
    • Helps us in improves the performance execution of the scripts.
      Headless browser saves time.

    Cons of Headless Browser:

    • Headless browser does not mimic the real execution of the test-cases.
    • It not possible to view the steps visually during the execution of the test-cases.

    Like our Facebook Page to get frequent updates->

    https://www.facebook.com/totalqa


    Selenium WebDriver Code

    1. Add the following dependency in the pom.xml to add the PhantomJS Library to the build path:


    2. Instead of the setting the path to the Phantom JS executable. Use the WebDriverManager class ensure the following depedency is added in the maven project object model (pom.xml) file.


    3. Execute the below code in eclipse and verify the results.

    Conclusion

    Selenium Code executed successfully without launching the Browser.

    HeadLess Browser using the PhantomJS Driver

    HeadLess Browser using the PhantomJS Driver

    using WebDriverManager class in Selenium WebDriver



    Selenium WebDriver automation tool is mainly useful to run tests against multiple Browsers such as Chrome Browser,Firefox Browser,Internet Explorer Driver.Running the tests against multiple browsers is known as Cross Browser Testing.
    To launch the Browser in Selenium WebDriver we need to set the path of the executable available in the laptop. Following that we have to instantiate the driver instance based on the Driver instance. In order to avoid these steps we can use the WebDriverManager class.

    WebDriverManager

    WebDriverManager allows to automate the management of the binary drivers (e.g. chromedriver, geckodriver, etc.) required by Selenium WebDriver.
    Using WebDriverManager its not required to maintain the below lines of the code for launching the browser.
    System.setProperty(“webdriver.chrome.driver”, “/path/to/binary/chromedriver”);
    System.setProperty(“webdriver.gecko.driver”, “/path/to/binary/geckodriver”);
    System.setProperty(“webdriver.opera.driver”, “/path/to/binary/operadriver”);
    System.setProperty(“phantomjs.binary.path”, “/path/to/binary/phantomjs”);
    System.setProperty(“webdriver.edge.driver”, “C:/path/to/binary/MicrosoftWebDriver.exe”);
    System.setProperty(“webdriver.ie.driver”, “C:/path/to/binary/IEDriverServer.exe”);

    WebDriverManager Maven Depdendency

    To use the WebDriverManager class ensure the following depedency is added in the maven project object model (pom.xml) file.


    Like our Facebook Page to get frequent updates->

    https://www.facebook.com/totalqa


    Selenium WebDriver Code

    Execute the below code in eclipse and verify the results.

    Steps to Launch the ChromeBrowser without using chromedriver.exe



    Selenium WebDriver automation tool is mainly useful to run tests against multiple Browsers such as Chrome Browser,Firefox Browser,Internet Explorer Driver.Running the tests against multiple browsers is known as Cross Browser Testing.
    To launch the Browser in Selenium WebDriver we need to set the path of the executable available in the laptop. Following that we have to instantiate the driver instance based on the Driver instance. In order to avoid these steps we can use the WebDriverManager class.

    WebDriverManager

    WebDriverManager allows to automate the management of the binary drivers (e.g. chromedriver, geckodriver, etc.) required by Selenium WebDriver.
    Using WebDriverManager its not required to maintain the below lines of the code for launching the browser.
    System.setProperty(“webdriver.chrome.driver”, “/path/to/binary/chromedriver”);
    System.setProperty(“webdriver.gecko.driver”, “/path/to/binary/geckodriver”);
    System.setProperty(“webdriver.opera.driver”, “/path/to/binary/operadriver”);
    System.setProperty(“phantomjs.binary.path”, “/path/to/binary/phantomjs”);
    System.setProperty(“webdriver.edge.driver”, “C:/path/to/binary/MicrosoftWebDriver.exe”);
    System.setProperty(“webdriver.ie.driver”, “C:/path/to/binary/IEDriverServer.exe”);

    WebDriverManager Maven Depdendency

    To use the WebDriverManager class ensure the following depedency is added in the maven project object model (pom.xml) file.


    Like our Facebook Page to get frequent updates->

    https://www.facebook.com/totalqa


    Selenium WebDriver Code

    Execute the below code in eclipse and verify the results.

    Capturing screenshot using java.awt.Robot class-Selenium WebDriver



    The java.awt.Robot class is mainly useful to perform native actions where keyword and mouse actions to be performed. This actions are helpful for automation. If the current platform configuration does not allow input controls, an AWTException will be thrown when using the java.awt.Robot class. In this post we will java.util.Robot class for capturing the screenshots. The method createScreenCapture(Rectangle screenRect) is available in java.awt.Robot class which helps to create an image containing pixels read from the screen.The java.awt.Rectangle object to be passed as an parameter for capturing the screenshot. To create an Rectangle object the java.awt.Dimension[Height*Width] object to be passed as an parameter.

    API Classes and Methods useful to capture the Screenshot as follows:

    • Robot Class Object
    • Rectangle Class Object
    • Dimension Class Object- Input Parameters Height * Width

    Selenium WebDriver Code

    Output:

    The full screen is captured as screenshot which is the expected outcome as shown below:

    Capture Screenshot using java.awt.Robot Class

    Capture Screenshot using java.awt.Robot Class

    Regex Pattern Matching in JAVA – String Functions startsWith(),endsWith(),contains()



    To identify particular pattern of regular expressions in Strings is achieved in JAVA by using the API java.util.regex. This API consists of two main java classes such as Matcher and Pattern classes. Also we can even use String Functions to identify the particular pattern of regular expressions in the String class.

    Pattern Class

    A regular expression specified as a String is passed into an instance of this class.
    The output is used to create a Matcher object that can match the character sequences against the regular
    expression.

    Static methods available in the Pattern Class as follows:

    • pattern()
    • split()
    • matcher()
    • compile()
    • matches()

    Matcher Class

    This java class helps to matches the character sequences by interpreting the pattern.

    Static Matcher Methods in the API:

    • start()
    • end()
    • group()

    Identify the List of Strings Starts with a particular letter

    Output of the Program:

    Result:: false
    Result:: false
    Result:: false
    Result:: true
    Start index: 0 End index: 1 Group value::t


    String Functions to identify the Regular Expressions:

    • startsWith(String prefix)
    • endsWith(String suffix)
    • contains(CharSequence s)

    Identify the List of Strings Starts with a particular letter using String Functions

    Output of the Program:

    String starts with a particular character:::total-qa
    String starts with a particular character:::tutorialpoint
    String ends with a particular character:::guru99
    String contains with a particular character:::total-qa
    String contains with a particular character:::javatpoint
    String contains with a particular character:::tutorialpoint


    Conclusion:

    Using the String functions and java.util.regex API, identification of the pattern in the given Strings is possible using the above examples.

    Add,Remove,Update – ArrayList,LinkedList,Vector Mock Interview Questions



    List is a type of Collection mainly useful to store the Objects which are duplicates as well. Its available in the package java.util.List. The behavior of the List is implemented by the java classes

    • ArrayList
    • LinkedList
    • Vector

    Java Mock Interview Questions about java.util.List as follows:

    1. Adding an new item to the List
    2. Adding an new item first to the List.
    3. Adding an item from in the middle of the List.

    4. Remove an item from the List.
    5. Remove an item from the List at particular index.
    6. Update an item from the List.

    Conclusion:

    Addition,Deletion and Updating the items of List is achieved using the methods available in the java.util.List package.

    Dynamic Input Test Data Generation: Best Practices,Random Java API



    In Testing it is important to provide input data to complete the execution of Test-cases. Irrespective of any type of testing such as Functional Testing,Integration Testing,System Testing and Performance Testing the input data plays a vital role.
    In Automation tools such as Selenium WebDriver the input data can be maintained in three different ways:

    1. Maintain parameters in the testng.xml. Read the parameter values using @Parameters annotation.
    2. Maintain input data in the Excel File. Read the data and pass the values using @DataProvider annotation.
    3. Input Data in the properties file.

    In the above 3 cases, the input data stored is static. If we suppose, the dynamic data should be generated used in the execution flow of test cases. We have to Java API to generate the dynamic data.
    So, we will go through now how to generate the random/dynamic input data.

    Note:
    Do not get confuse with the dynamic object properties. In this post we are discussing about only the input data.

    Generating two digit Random Number

    java.util.Random is a java class available for generating random integers.

    Generating three digit Random Number

    Generating Random ASCII Character

    To generate the random characters we should glance through the ASCII table from this link.
    http://www.asciitable.com/

        Lower Case Alphabets– Decimal Number Ranging from 97 to 122
        Upper Case Alphabets– Decimal Number Ranging from 65 to 90

    Generating five digit Random Number

    Conclusion:

    The Dynamic input data generated is useful to execute the test case in different Testing Environment without any dependency on resource files.