Monday, July 29, 2019

Cypress WebAutomation Tool

This is web automation tool ( Non-selenium Framework).


Cypress Supporting browsers:
Canary
Chrome
Chromium
Electron


Cypress will detect all the browsers automatically if the browsers are available In your computer.
If you have chrome browser in Mac book then open cypress with chrome.

If you want to open chrome browser with Cypress then use the below command.
./node_modules/.bin/cypress open --browser chrome

but make sure you should able to open chrome browser with terminal. then only the above command works. If you not installed your chrome browser in the Application folder in your MacBook then first install chrome browser in Application folder. please see here how to open chrome browser from terminal in Mac OS.

You can see the 




Like the above pic you can see the browser name which you have  opened.
if you open Cypress normally then also you can see the available browsers and you can select and run.


Launch Chrome browser from Terminal in Mac OS

First download the chrome browser "googlechrome.dmg" file
move this file in to Application folder
double click on "googlechrome.dmg" file
it will install chrome in application folder.
open Terminal
Open ~/.bash_profile file in your editor choce
example:
vim  ~/.bash_profile

Add the following code in the bash profile file

chrome() {
open -a "Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" "$1"
}
save the bash profile file

use the below command to open chrome from terminal"
open -a "Google Chrome"

Google Chrome browser will launch

Thursday, July 25, 2019

getAttribute value from html when the input tag is disable.

.getAttribute(“textContent”);
This is more important when your application developed with Angular.
When you want to get the test from a WebElement then we will use “.getText”
or any available attribute from the given tag of WebElement. I tried my best but did not get the text from the WebElement from the below code.

>

Both tags are siblings. I want to get a text from input box. input box is editable and it is rendering the value from previous page. But the rendering value of input box is not showing in the “input” tag. it is showing in the “label” tag. If you give the css or xpath for label tag and use the get text then also you are getting the value from the input box.  I tried with many options but no use. i got solution from “stack overflow” and tried with  “.getAttribute(“textContent”); ” then i got the rendering value from input box.

Sunday, July 21, 2019

Create Batch file and run

We can create batch file to execute selenium test cases with one click.
you no need to navigate or open eclipse and choose the test case to execute the cases.  once we set up all the cases as suite and create a batch file then we can run the batch file with one  click then it will execute test suite and send the result.

create a batch file is open note pad and save as "rub.bat" and select the file type save as "Batch file"
then it will save as batch.
inside the batch file you can mention what you want to run.
ex:
java -cp D:\sasiWorkspace\PlyMouth\bin; D:\sasiWorkspace\PlyMouth\lib-314159\* org.testng.TestNG testng.xml

It will run the testg.xml file
In this xml file we can mention the suite ( with number of test cases).
bin path from the project folder to get the .class files
lib path from the project folder or outside. it will access the libraries to execute the classes.

Open the command prompt and go to the batch file location.
Example your batch file saved in the your project folder inside the workspace.

D:\workspaceName\projectName>rub.bat

IT will execute the batch file and after complete the testsuite.

Saturday, July 20, 2019

How to run TestNGXML file from command prompt in windows

Open Command prompt.
Go to workspace ( project workspace)
D:\Workspace\testProject>
Project workspace should have lib folder which contain all libraries ( which you have added in the project referenced libraries  in the project build path)

Create a testng.xml file which you want to run through testng

use the below command to execute testngXML file
java -cp D:\\\bin; D:\\\lib-314159\* org.testng.TestNG testng.xml

Saturday, July 20, 2013

How to update a string content with out using string in java.



This is very simple question, but some people think too much..and could not found solution..
one of my fren got this question from interview. he was failed to answer this in that interview..
We have solution now by using "replace/replaceAll"

ex :
I am staying in Hyderabad.
he wants to update "Hyd" to "Cyb". then out put should be "I am staying in Cyberabad"

System.out.println( "I am staying in hyderabad, im studing in hyderabad".replaceAll("hyd", "cyb"));

Tuesday, October 18, 2011

Separate Firefox profile with SeleniumRC


package com.sample;


import com.thoughtworks.selenium.*;


import java.io.File;
import java.util.regex.Pattern;


import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;


public class Test67 extends SeleneseTestCase {
public Selenium selenium;
public Selenium settingup()throws Exception {
File template = new File("C:\\Documents and Settings\\sasidhar\\Application Data\\Mozilla\\Firefox\\Profiles\\Selenium");
RemoteControlConfiguration rc = new RemoteControlConfiguration();
rc.setFirefoxProfileTemplate(template);
SeleniumServer seleniumServer = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://google.com/");
seleniumServer.start();
selenium.start();
selenium.open("https://google.com");
selenium.windowFocus();
selenium.windowMaximize();
return selenium;
}

public void testUntitled() throws Exception {
selenium.open("about:home");
selenium.type("id=searchText", "sasidhar");
selenium.click("id=searchSubmit");
selenium.waitForPageToLoad("30000");
}
}