admin

Selenium WebDriver – Executing JavaScript

If we need to execute javaScript on Selenium WebDriver,

Clicking on WebElement
JavascriptExecutor js = (JavascriptExecutor) vDriver;
js.executeScript(“var InputElements = document.getElementsByTagName(‘button’);”
               + “InputElements[1].click();”);

Another way:
js.executeScript(“var InputElements = document.getElementsByTagName(‘button’);”
                              + “for (i=0; i                              + “{“
                              + “if(InputElements[i].value == ‘‘)” 
                              + “{“
                              + “InputElements[i].click();”
                              + “}”
                              + “}”
                              + “InputElements[1].click();” );

Scrolling to specific WebElement
js.executeScript(“window.scrollTo(“+vElementsList.get(1).getLocation().getX()+”,             “+vElementsList.get(1).getLocation().getY()+”)”);

Loading Alert Pop-up
js.executeScript(“alert(‘hello world’)”);
  • Working on Desktop Browsers(mostly known) using Selenium WebDriver
  • Working on Mobile Browsers(ChromeDriver, SafariDriver) using Appium

Branching

“Branching, in revision control and software configuration management, is the duplication of an object under revision control (such as a source code file, or a directory tree) so that modifications can happen in parallel along both branches.

The originating branch is sometimes called the parent branch, the upstream branch (or simply upstream, especially if the branches are maintained by different organisations or individuals), or the backing stream. Child branches are branches that have a parent; a branch without a parent is referred to as the trunk or the mainline.[1]

In some distributed revision control systems, such as Darcs, there is no distinction made between repositories and branches; in these systems, fetching a copy of a repository is equivalent to branching.

Branching also generally implies the ability to later merge or integrate changes back onto the parent branch. Often the changes are merged back to the trunk, even if this is not the parent branch. A branch not intended to be merged (e.g. because it has been relicensed under an incompatible license by a third party, or it attempts to serve a different purpose) is usually called a fork.”

Trunk

Trunk refers to the unnamed branch (version) of a file tree under revision control.
The trunk is usually meant to be the base of a project on which development progresses.
If developers are working exclusively on the trunk, it always contains the latest cutting-edge version of the project, but therefore may also be the most unstable version.

Another approach is to split a branch off the trunk, implement changes in that branch and merge the changes back into the trunk when the branch has proven to be stable and working. Depending on development mode and commit policy the trunk may contain the most stable or the least stable or something-in-between version.

Often main developer work takes place in the trunk and stable versions are branched, and occasional bug-fixes are merged from branches to the trunk. When development of future versions is done in non-trunk branches, it is usually done for projects that do not change often, or where a change is expected to take a long time to develop until it will be ready for incorporating in the trunk.

Selenium WebDriver – Using AdvancedUserInteractions API

The Advanced User Interactions API is more comprehensive API for describing actions a user can perform on a web page such as drag and drop or clicking multiple elements while holding down the Control key.

Actions vMyActions = new Actions(vDriver);
      vMyActions keyDown(Keys.CONTROL)
        .click(someElement)
        .click(someOtherElement)
        .keyUp(Keys.CONTROL);

Then get the action:

   Action vBindAction = vMyActions.build();

And execute it:

   vBindAction.perform();

  • It supports single and composite actions for Mouse and Keyboards
  • It supports most of common browsers including mobile browsers

source

Following are my reusable custom actions, will add more as needed 🙂

 1. MouseMove
Move mouse over an element, usually to get hover

Locatable vElement = (Locatable) vDriver.findElement(by);
Mouse vMouse = ((HasInputDevices) vDriver).getMouse();
vMouse.mouseMove(vElement.getCoordinates());

2. Drag and drop
I need to drag and element on some other element,

vFirtElement = vDriver.findElement(By.id(“id));
vContaingerElement = vDriver.findElement(By.id(“containerid));
new Actions(vDriver). dragAndDrop(vFirtElement, vContaingerElement).build().perform();

3. Drag and Drop By
I need to drag and element from one place to other,

vElementToDrag = vDriver.findElement(By.id(“id”));
new Actions(vDriver).dragAndDropBy(vElementToDrag, 120, 1100).build().perform();

4. Select multiple elements
If I need to check/select multiple list items,

List vList = vDriver.findElements(By .cssSelector(“.class));
Actions vClickMultiple = new Actions(vDriver);
 vClickMultiple.clickAndHold(vList.get(1))
        .clickAndHold(vList.get(2))
        .click();
Action vBindActions = vClickMultiple.build();
 vBindActions.perform();

5. Slide
we can use dragAndDropBy to emulate sliding event

vElementToSlide = vDriver.findElement(By .className(“class”));
new Actions(vDriver).dragAndDropBy(vElementToSlide, 120, 0).build().perform();

Setting up .gitignore to ignore unwanted contents at cloud

.gitignore file should be at root of the project with following pattern,

  • Add the file name like project.settings to ignore it
  • If we need to ignore multiple files with same extensions we can use *.settings
  • If we need to ignore multiple files in a directory with same extensions we can use /src/*.xml
  • If we needs to ignore a directory with its all contents, we can use /bin/*

my .gitignore:

/bin/*
/gen/*
/results/*
*.class
*.log
*.png
.project
.classpath
.hg
.settings

A Tester should sleep enough :)

Enough Sleep is very improment to be efficient,

I belive Efficiency is ability to find iceberg before it hits the Titanic

  • The demands and expectations of our modern society have placed increasing demands on our time, and more than ever people are making up for those demands by cutting back on sleep.
  • At the same time, it is becoming increasingly clear that the cost of insufficient sleep is much higher than most people recognize.
  • Scientific research is revealing, for example, how sleep loss, and even poor-quality sleep, can lead to an increase in errors at the workplace, decreased productivity, and accidents that cost both lives and resources. Awareness can help you improve your sleep habits and in turn your safety.

Here is good article showing scientific proves on it 🙂

http://healthysleep.med.harvard.edu/healthy/matters/consequences/sleep-performance-and-public-safety

GeoSurf The world’s #1 premium proxy toolbar

GeoSurf™ by BIScience is an easy to use add-on that enables users to access premium proxy gateways in 100+ global locations to surf geo-targeted local content directly from your browser. With GeoSurf™ you can experience any web page or web content as it resolves to a local user from each of our 100+ global locations.

Check out TechCrunch review of GeoSurf™:
techcrunch

In order to use the service you need a GeoSurf™ account which can be purchased here: site With GeoSurf™ one can:

1. Keep control of your campaigns and make sure they are deployed properly.
2. Access your web sites (and your competitors’!) as if coming from different locations to perform QA and view geo-targeted content and advertising.
4. Follow funnels to ensure all targeting is functioning properly.
5. Test your applications and geo-targeted web content in real time.
6. View websites as they are resolved to different mobile devices using the mobile emulator feature.

Its great experience using this tool 🙂 and I am happy to add it in my tools list. 

Getting Running Services on Android

Put following code snippet into TestProject and get list of all running services over android Phone,

ActivityManager vActivityManager = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);       

        Log.i(“TestingService”, “Total are”+manager.getRunningServices(Integer.MAX_VALUE).size());

        for (RunningServiceInfo vRunningServices : manager.getRunningServices(Integer.MAX_VALUE))
        {                       
            Log.i(“TestingService”, “PackageName: “+vRunningServices.service.getPackageName());
            Log.i(“TestingService”, “ClassName: “+vRunningServices.service.getClassName());
            Log.i(“TestingService”, “ShortClassName: “+vRunningServices.service.getShortClassName());
            Log.i(“TestingService”, “——————————————-“);
        }