How to find the alpha characters in a given string

How to find the alpha characters in a given string

 

Dim objStr

Dim objLength

Dim objChar

objStr=”1q2w3etest”

objLength=len(objStr)

alphacount=0

For i=1 to objLength

If not isnumeric (mid(objStr,i,1)) then

alphacount =alphacount+1

alphacharacter  = alphacharacter & mid(objStr,i,1)

End if

Next

msgbox “alpha chara count is  ” & alphacount

msgbox “alpha charaters are :   ” & alphacharacter

How to run java script on webdriver

Steps,

  1. create a java project using Eclipse IDE
  2. add a package and then a class (refer below code for package name and class name)
  3. then add necessary jar files (selenium-server-standalone-2.53.0, testing, etc)
  4. then copy/paste and update the code in your IDE
  5. place chromedriver in the folder and update code below for folder “Users/shali/Downloads/” path matching your pc folder
  6. run your script to verify results.

JavaScriptExample;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.remote.DesiredCapabilities;
public class JavaScriptTest {
public static void main(String[] args) {
 System.setProperty(“webdriver.chrome.driver”, “/Users/shali/Downloads/chromedriver”);
 ChromeOptions options = new ChromeOptions();
options.addArguments(“window-size=1024,680”);
 DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);
 driver.get(“https://shalimatech.com/”);
 if (driver instanceof JavascriptExecutor) {
((JavascriptExecutor) driver)
.executeScript(“alert(‘testing for java script’);”);
}
  }
}

Dockers vs Virtual machines

Dockers vs Virtual machines, a quick note about the difference between two.

Docker is an open source tool used to make package of an application which contains all required libraries , dependent programs, files etc. Docker makes it easy to create , deploy and execute application programs.  Docker will give the surety that application will work without any issues in any given machine..

 However Virtual machines(VM) used to create virtual Operating system(OS) and are designed to run OS on servers. VM will emulate hardware. However Containers are faster and lighter than VM.

 

How to run jmeter in jenkins

How to run jmeter in jenkins

steps:

Jenkins setup and performance plugin setup:
1) copy performance plugin into Jenkin’s home directry before you start the test.
2) to do that – you can download the performance plugin “performance.hpi” from the site https://wiki.jenkins-ci.org/display/JENKINS/Performance+Plugin
3) how to find the home directry of jenkins – to do that you can navigate to jenkins home page (localhost:8080) and then
4) click on “Manage Jenkins” and then click on “Configure system” the you will notice “Home directy” path in there.

Configure Jmeter and create a basic script in Jmeter:
5) download Jmeter Binary zip file from Jmeter site http://jmeter.apache.org/download_jmeter.cgi
6) unzip it and go to the “bin” directory of the Jmeter folder, wherre you will notice “user.properties” file.
7) open the file in notepad or notepad++ or any other text editor
8) add a line “jmeter.save.saveservice.output_format=xml” to that. Save and close the “user.properties” file
9) create a Jmeter script and make sure you can run it in non GUI mode i.e either in DOS mode or using shell scripts in MAC (note down the commands used in respective OS and it could be used in Jenkins job setup)
Note: for windows command line run, you can use the following commands

C:\[JMETER BIN directory]\jmeter.bat -Jjmeter.save.saveservice.output_format=xml -n -t C:\[JMETER script “.jmx” file] -l Jmeter_test_results.jtl

Note 1: For detailed topics on Jmeter scripts creation , please visit Jmeter , Jmeter recording 

setup Jenkin’s job to run Jmeter scripts
9) go to Jenkins home page (localhost:8080) and then click on “New Item” on “Freestyle project”
10) in the “New item” page, give some name in the item name field and go to below to section “Build” and add build step
11) add build step can be either a) “execute windows batch command” for windows or b) “Execute shell” for MAC
12) provide your command in there and save.
13) Click on “Build now” which would call the Jmeter (jmx) file and run the program
14) after the run, you can verify the Jenkins console to review the results.

Selenium jenkins integration

Selenium jenkins integration steps are as below:
Jenkin related steps:
1) start jenkins by running command in DOS prompt (detailed steps in here )
2) then make sure you are able to access url : localhost:8080
3) then you need to configure jenkins to run the selenium scripts – for that click on “Manage Jenkins”
4) then click on Configure systems
5) Find out the jdk files are installed (usually in C:\ program files … folder path) and copy paste the path in JDK section “JDK Installations” in ” Configure systems” which you are already in.
6) Give JDK name “JAVA_HOME” and provide Java path below in the next field.
Selenium related steps:
3) Open eclipse IDE and start new Java project
4) make sure you added selenium jars (Selenium server standalone jar file which you can download add to new project) to support selenium framework for your automation testing.
5) then create a simple selenium script – make sure it is running and completing successfully in Eclipse.
6) Also create a xml file give a name “Xml1.xml”  Make sure Run “Xml1.xml” as “TestNG Suite” is working fine in Eclipse. Also notedown the xml file path in selenium project. create a lib folder in that and add all jar files which are required.
Commmand prompt:
7) navigate to that project folder in command prompt and set all required classpath like bin and lib etc which are already in xml file folder in selenium project which you got from selenium project in eclipse.
8) then type command “Java org.testng.testNG Xml1.xml” which will display results in command prompt/DOS screen
9) now create a batch file “Batch1.bat” which contains the above command and also a command for compiling as e.g “java -cp bin;lib/* org.testng.testNG Xml1.xml”
Jenkins setup to build and run the file:
10) in Jenkins, create a “new item” with selection of “Freestyle project”
11) then select “Advance options” and put the Selenium project home directory path in there.
12) the build trigger section, select Batch file execution option in there, then put the batch file name “Batch1.bat”
13) click and save the new item
14) click on “Build Now” and verify the “Console output”

qtp integration with jenkins

qtp integration with jenkins

Create a “.vbs” file as below and save the file as “AOM.vbs” in C:\QTP\VBS folder.

 In Jenkins create Job, Select ‘Execute Windows Batch Command’ in Build Step. Enter below command.

 and then use that in Jenkins.

Note: To learn how to create a Jenkins job or how to start jenkins – please refer  create a Jenkins job and Run Jenkins locally

 Below code is the “AOM.vbs” which is called by Jenkins Job.

Call QTP()

Public function QTP()

‘Create Quick test pro(QTP/UFT) object

Set objQTP = CreateObject(“QuickTest.Application”)

objQTP.Launch

objQTP.Visible = True

‘to open QTP Test

objQTP.Open “Test file path “, True

Set objResults= CreateObject(“QuickTest.RunResultsOptions”)

objResults.ResultsLocation = “Result path of qtp”  ‘Set the results location

‘to run qtp script results

objQTP.Test.Run objResults

‘to close QTP

objQTP.Test.Close

objQTP.Quit

End function

Jenkins and github integration

Jenkins and github integration

1) open a browser and type “localhost:8080”

2) Click on Manage Jenkins link on the left side panel

 

 

 

 

 

3) which opens a list of options and click on the Manage plugins link

 

 

 

 

 

4) which opens a page with “available” tab and search option. where search for “Github plugin”

5) click on the Github plugin  and install it.

6) then create a “new item” and select “Git” in the source control management section.

 

 

 

 

 

How to run jenkins locally

How to run jenkins locally

1) go to https://jenkins.io and download Jenkins.war file
2) place the war file in a folder (e.g. C:\Jenkins\Jenkins.war )
3) then open command prompt (windows start menu > run > cmd will open command prompt )
4) in command prompt, go to folder C:\Jenkins\ ( command : “CD C:\Jenkins\” )  and then run command ” java -jar Jenkins.war “
5) this will exract a folder name “.jenkins” into your user folder ( the path is usually “C:\users\”your login”\.jenkins”
6) copy “.jenkins” folder and paste to folder C:\Jenkins\, so that you have “C:\Jenkins\.jenkins” as the folder path.
7) Now you setup a Enviroment variable (to set up that go to Control panel > system > Advanced System settings )
8) then add Enviroment variable as “JENKINS_HOME” and value as “C:\Jenkins\.jenkins”

you all set to run Jenkins on your machine !

open a browser and type “localhost:8080”

Text file handling in QTP

Text file handling in QTP

Const ReadTXT = 1
Const WriteTXT = 2

Set objFSO = CreateObject(“Scripting.FileSystemObject”)

‘Suppose you have 100 TXT files needs to be read and updated – then load those files in input XLS file.
FilePath = Datatable(“FilePath”) & “.txt”

Set objFile = objFSO.OpenTextFile(FilePath, ReadTXT)

strText = objFile.ReadAll

objFile.Close

strNewText = Replace(strText, Datatable(“OldValue”), Datatable(“NewValue”))

Set objFile = objFSO.OpenTextFile(FilePath, WriteTXT)

objFile.WriteLine strNewText

objFile.Close