Monday, September 17, 2018

Write response to a txt file groovy script on SoapUI


import net.sf.*; import net.sf.json.*; import net.sf.json.groovy.*; import net.sf.json.groovy.JsonSlurper; def Res = context.expand( '${GetAllSchoolsForAustralia#Response}' ) def slurper = new JsonSlurper() def json = slurper.parseText Res def countryList = json.result._source.city log.info countryList def file = new File('D:/XXX/CityListAU.txt'); file << countryList

Friday, September 7, 2018

Count child nodes of a JSON response using groovy in soapui



import net.sf.*;
import net.sf.json.*;
import net.sf.json.groovy.*;
import net.sf.json.groovy.JsonSlurper
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)

//Getting response from methods
def response = context.expand( '${Request 1#Response}' ).toString()

def slurper = new JsonSlurper()
def json = slurper.parseText response
def countryList = json.result.size()
def ActualResultNodeCount=countryList - 1
log.info ActualResultNodeCount


This is also very useful when accessing  test case data.
import java.net.*
def ts = context.testCase.getTestStepByName("RequestMaori-culture")
def endpoint =ts.getPropertyValue('Endpoint')
log.info endpoint

Wednesday, September 5, 2018

How to work with Windows image upload or file browser window on selenium with Jave

There are are several methods to handle this kinds of situation but not all are working ,Because most of them are to use with HTML file browser windows ,
This solution is specially for Windows file browser window AKA Windows file browser dialog box.

User first need to click on the file browser button,The there will be a Windows file browser dialog box where you can browse for a file.

In a nut shell what we are doing is just Copy and Past the file path at the Windows file browser dialog box

try {
    StringSelection s = new StringSelection("C:\\Users\\XXX\\Pictures\\w.png");
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(s, null);
    Robot robot = new Robot();

    robot.keyPress(java.awt.event.KeyEvent.VK_CONTROL); //Press CTRL KEY
    robot.keyPress(java.awt.event.KeyEvent.VK_V);//Press V KEY
    robot.keyRelease(java.awt.event.KeyEvent.VK_CONTROL); //RELEASE CTRL KEY
    Thread.sleep(3000);
    robot.keyPress(java.awt.event.KeyEvent.VK_ENTER);
} catch (AWTException e) {
    e.printStackTrace();
} catch (InterruptedException e) {
    e.printStackTrace();
}

try {
    Thread.sleep(60000);
} catch (InterruptedException e) {
    e.printStackTrace();
}

Monday, September 3, 2018

java: cannot access java.util.function.Function class file for java.util.function.Function not found - Selenium on JAVA with InteliJ

I have below two lines on my selenium code.

WebDriverWait wait = new WebDriverWait(driver, 100);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(DashObj.HeaderText));

When i execute the test method as on the tittle im getting an error saying 
"java.util.function.Function class file for 
java.util.function.Function not found"

Fix:
Go to File ->Project Structure

There will be an window with some configurations.
Go to Modules and locate the Language level at Sources tab,


By default it was set to 7 , So click on the drop down and set it to 8.


Tuesday, July 24, 2018

Configuring Jenkins with MSSQL server.


  • Need to install SQL server.
  • Install Java.
  • SQL server is with SQL authentication method.

Below is the sonar config looks like ,But im getting an error.


sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=SonarQube;instanceName=SQLEXPRESS
sonar.jdbc.username=sonarqube
sonar.jdbc.password=mypassword

java.lang.IllegalStateException: Can not connect to database. Please check connectivity and settings (see the properties prefixed by 'sonar.jdbc.').


Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' for connect URL 'jdbc:sqlserver:localhostSQLEXPRESS;databaseName=SonarQube;instanceName=SQLEXPRESS;selectMethod=cursor;'

Full post:
http://blog.majcica.com/2016/04/28/sonarqube-on-windows-and-ms-sql/

Wednesday, July 11, 2018

Show MSTest coverage on a .net project - Sonar

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Dynami
c Code Coverage Tools>CodeCoverage.exe 
collect /output:VisualStudio.coverage "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "C:\Program Files (x86)\Jenkins\workspace\dash_\dash\ReportShare\bin\ReportShare.dll"



  1. You have to find the CodeCoverage.exe installation location.

In my PC its inside "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Dynami
c Code Coverage Tools>"

  2.Execute your MSTest dll file by pointing it to CodeCoverage.exe

     3. Then VisualStudio.coverage file will be generate on your CodeCoverage.exe's file location.



C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Dynami
c Code Coverage Tools>CodeCoverage.exe analyze /output:VisualStudio.coveragexml VisualStudio.coverage

  
  4.By pointing to the same CodeCoverage.exe generate the coveragexml file.

     5. Then VisualStudio.coveragexml file will be generate on your CodeCoverage.exe's file           location.




sonar.cs.vscoveragexml.reportsPaths=C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Team Tools/Dynamic Code Coverage Tools/VisualStudio.coveragexml

   6.Then add sonar.cs.vscoveragexml.reportsPaths parameter to your sonar analysis properties and point the newly generated  VisualStudio.coveragexml  file to that property.




DONE!

Tuesday, April 3, 2018

Easy way to switch between windows on appium or selenium

ReadOnlyCollection<string> windowHandles = driver.WindowHandles;
            driver.SwitchTo().Window(windowHandles[1]);