Tuesday, 30 December 2014

pom.xml does not exist selenium java

pom.xml does not exist selenium java

In your pom.xml you are using modules..  so  you have to include

There must absolutely be a pom.xml file under projectName, and it must have an artifact id that matches the one under the parent declaring the module, i.e.

<artifactId>projectName</artifactId>


OR else

use this on pom.xml


<packaging>pom</packaging>


http://stackoverflow.com/questions/26021141/maven-child-module-does-not-exist

Project build error: 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging.

Project build error: 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging.

Add this to your pom.xml it solves the problem.
 
 
  <packaging>pom</packaging>
 
 
  if the parent project contains source code, I strongly suggest you to:

move this code in a new module (let's call it commons)
make commons a child module of your parent project
add the commons module as a dependency of all other modules requiring it (maybe all of them)
add <packaging>pom</packaging> in the parent pom.xml


More details you can have a look on this...

Thursday, 11 December 2014

How to wait until the element is present or load a banner in selenium java cucumber

Here the way how to wait until the element is present .

there are many ways to do this..

Thread.sleep(1000) is old static way of doing...

If you are waiting to load any image or banner or progress bar then you have to use javascriptexecutor technique

Another trick is to realise that the WebDriver instances implement JavascriptExecutor. This interface can be used to execute arbitrary Javascript within the context of the browser (a trick selenium finds much easier). This allows us to use the state of javascript variables to control the test. For example – we can have a variable populated once some asynchronous action has completed; this can be the trigger for the test to continue.

First, we add some Javascript to our example page above. Much as before, it simply loads a new page and updates the <div> with this content. This time, rather than show the div, it simply sets a variable – “working” – so the div can be visible already.

   

 /**
 * Call this method before an event that will change the page.
 */
private void beforePageLoad() {
    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("document.mpPageReloaded='notYet';");
}

/**
 * Call this method after an event that will change the page.
 *
 * @see #beforePageLoad
 *
 *      Waits for the previous page to disappear.
 */
private void afterPageLoad() throws Exception {
    (new WebDriverWait(driver, 10)).until(new Predicate<WebDriver>() {

        @Override
        public boolean apply(WebDriver driver) {
            JavascriptExecutor js = (JavascriptExecutor) driver;
            Object obj = js.executeScript("return document.mpPageReloaded;");
            if (obj == null) {
                return true;
            }
            String str = (String) obj;
            if (!str.equals("notYet")) {
                return true;
            }
            return false;
        }
    });
}

 http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/JavascriptExecutor.html

http://stackoverflow.com/questions/5868439/wait-for-page-load-in-selenium

Way 1:

WebDriverWait wait = new WebDriverWait(driver, 15);
  wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("xpath here")));
 
  System.out.print("Text box text3 is now visible");

Way 2:

In webdriver:
driver.findElement(By.id("")).isSelected or Enabled or Displayed)
{
//actions
Do some thing...
}

Way 3:

 //To verify element is present on page or not.
   String XPath = "//input[@id='text"+i+"']";
   Boolean iselementpresent = driver.findElements(By.xpath(XPath)).size()!= 0;
   if (iselementpresent == true)
   {
    System.out.print("element present..");
   }
   else
   {
    System.out.print("Element is not present");
   }


Way 4:

  if(selenium.isElementPresent(objectId)) 
//** it will check for the ObjectID in the Input sheet
                    {
                        driver.findElement(By.id(objectId)).clear();
 //** it will execute ,once it got the respective ObjectID

 }

Ref

http://stackoverflow.com/questions/20903231/selenium-wait-until-element-is-present

http://www.selenium-automation.co.uk/blog/selenium-iselementpresent-in-webdriver/

http://stackoverflow.com/questions/19851518/selenium-webdriver-wait-for-element-to-be-present-when-locating-with-webdriver

Wednesday, 24 September 2014

Easy to use editor to navigate from feature files to step definations for jvm Cucumber in eclipse

To navigate from feature files to step definitions easily .. you can use this Natural plug in.  
You can download this file from here

https://github.com/rlogiacco/Natural/wiki/Installation-Guide

Download Natural.zip file manually to your local machine

Open Eclipse 
Help-> Install New software

On available software click on Add button

Click on Archive button choose Nature.zip file and install .

Restart Eclipse 

If you are not sure how to archive file you can get help here
http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.platform.doc.user/tasks/tasks-127.htm


Now it will works.

Friday, 19 September 2014

How to check whether css selector is correct or not in Chrome selenium inspect elements

How to check whether css selector is correct or not in Chrome selenium inspect elements


Open Chrome browser
Right Click on any element click Inspect elements as a result you will get development tool

Select Console Tool there


And after that


$$(" here give your css selector path ")

for xpath we can check like this
$x('//*[@id="header-container"]')

And click enter path should select .

Tuesday, 29 July 2014

Guice provision errors on mac selenium cucumber automation java

Guice provision errors on mac

This problem occurs due to technical path errors
In my case I have given wrong path for chrome as below.. thats why its came.. After correcting path.. it resolved.

I have given this path as per windows .. thats why this path is not working on mac ... hence the below error occuring..

/Users/usreid/Desktop/automationframework/\\Applications\\Google Chrome.exe] 

After that I have change my path as per mac the it started working fine.

Click here how-to-setup-chrome-driver path -on-mac


Failure in after hook:RegistrationHooks.signOut()

Message: com.google.inject.ProvisionException: Guice provision errors:
1) Error in custom provider, org.openqa.selenium.WebDriverException: The chrome binary [/Users/usreid/Desktop/automationframework/\\Applications\\Google Chrome.exe] does not exist.

Build info: version: '2.37.0', revision: 'a7c61cbd68657e133ae96672cf995890bad2ee42', time: '2013-10-18 09:51:02'

System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.2', java.version: '1.6.0_65'

Driver info: driver.version: unknown

  while locating com.comapanyname.selenium.WebDriverProvider

  at com.comapanyname
.configuration.guice.WebDriverModule.configure(WebDriverModule.java:15)

  while locating org.openqa.selenium.WebDriver

    for parameter 1 at com.comapanyname.selenium.DocumentAccessor.<init>(DocumentAccessor.java:31)

How to setup chrome driver on mac selenium bdd cucumber automation

How to setup chromedriver path on mac laptop to selenium cucumber automation scripts.

1) First download chrome driver from the following path

2)  From your mac search for "AppleScript Editor"
AppleScript Editor will open editor please paste the below code and click run
do shell script "/Applications/Chromium.app/Contents/MacOS/Chromium --user-data-dir=/Users/$USER/Library/Application\\ Support/ChromiumPersonal > /dev/null 2>&1 &”
Popup window will come and ask you to enter untittled name
enter "Chrome" Save it on Applications location.
3)Open chrome browser which is already installed on your mac and type below link on browser url
//Applications//Google Chrome.app//Contents//MacOS//Google Chrome
It will download chrome ... let it download
Then go to your Selenium or cucumber java code give this path as chrome driver path 
'//Applications//Google Chrome.app//Contents//MacOS//Google Chrome'
Now it should work . Note in MAC there is no .exe just like in windows system.Here we use above path.

If you feel it is useful please share on facebook and please like on facebook icon.