TESTEVERYTHING

Tuesday, 25 November 2014

Calabash-iOS commands

irb(main):021:0> query("label all",:text)
[
    [ 0] "Home",
    [ 1] "Pull down to refresh",
    [ 2] "FTSE",
    [ 3] "6739.27*",
    [ 4] "+0.14%",
    [ 5] "+9.48",
    [ 6] "DAX",
]

irb(main):023:0>  query("button index:0").first.keys
[
    [0] "selected",
    [1] "enabled",
    [2] "rect",
    [3] "id",
    [4] "description",
    [5] "label",
    [6] "alpha",
    [7] "class",
    [8] "frame"
]
irb(main):024:0>  query("button index:0").first.values
[
    [0] false,
    [1] true,
    [2] {
        "center_x" => 25,
               "y" => 26,
           "width" => 20,
               "x" => 15,
        "center_y" => 37,
          "height" => 22
    },
    [3] nil,
    [4] "<ButtonMostTappable: 0x1673a670; baseClass = UIButton; frame = (15 26; 20 22); opaque = NO; layer = <CALayer: 0x16736f80>>",
    [5] "ThreeLines",
    [6] 1,
    [7] "ButtonMostTappable",
    [8] {
             "y" => 26,
         "width" => 20,
             "x" => 15,
        "height" => 22
    }
]
irb(main):025:0> query("button index:0").first["frame"]["x"]
15


irb(main):026:0> classes("view")
[
    [ 0] "UIWindow",
    [ 1] "UIView",
    [ 2] "UIView",
    [ 3] "MMDrawerCenterContainerView",
    [ 4] "UIView",
    [ 5] "UIImageView",
    
]
irb(main):027:0> classes("*")
[
    [ 0] "UIWindow",
    [ 1] "UIView",
    [ 2] "UIView",
    [ 3] "MMDrawerCenterContainerView",
    [ 4] "UIView",
    [ 5] "UIImageView",
    [ 6] "UIView",
]
irb(main):028:0> classes("UIImageView").count
13
uia_tap_mark "header search"
uia_type_string "Appl"
query("view:'UITableViewCellContentView' label", :text)
query("*", :accessibilityLabel)
query("button", :accessibilityLabel)
query("label all",:text)
uia_tap_mark "ThreeLines"
uia_tap_mark "Create New Watchlist"
uia_type_string "QA_Test_List"
uia_tap_mark "Done"
touch("view:'UISearchBarTextField'")
uia_type_string "Appl"
uia_tap_mark "Apple Inc (AAPL)"
query("view:'UILabel'{accessibilityLabel ENDSWITH 'EUROPE'}")
[
    [0] {
               "text" => "EUROPE",
            "enabled" => true,
               "rect" => {
            "center_x" => 160.25,
                   "y" => 396,
               "width" => 43.5,
                   "x" => 138.5,
            "center_y" => 404,
              "height" => 16
        },
                 "id" => nil,
        "description" => "<UILabel: 0x17f57720; frame = (138.5 3; 43.5 16); text = 'EUROPE'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x17d99ea0>>",
              "label" => "EUROPE",
              "alpha" => 1,
              "class" => "UILabel",
              "frame" => {
                 "y" => 3,
             "width" => 43.5,
                 "x" => 138.5,
            "height" => 16
        }
    }
]
query("view:'UILabel'{accessibilityLabel BEGINSWITH 'EUROPE'}")
[
    [0] {
               "text" => "EUROPE",
            "enabled" => true,
               "rect" => {
            "center_x" => 160.25,
                   "y" => 396,
               "width" => 43.5,
                   "x" => 138.5,
            "center_y" => 404,
              "height" => 16
        },
                 "id" => nil,
        "description" => "<UILabel: 0x17f57720; frame = (138.5 3; 43.5 16); text = 'EUROPE'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x17d99ea0>>",
              "label" => "EUROPE",
              "alpha" => 1,
              "class" => "UILabel",
              "frame" => {
                 "y" => 3,
             "width" => 43.5,
                 "x" => 138.5,
            "height" => 16
        }
    }
]
query("view {text BEGINSWITH 'EUROPE'}")
[
    [0] {
               "text" => "EUROPE",
            "enabled" => true,
               "rect" => {
            "center_x" => 160.25,
                   "y" => 396,
               "width" => 43.5,
                   "x" => 138.5,
            "center_y" => 404,
              "height" => 16
        },
                 "id" => nil,
        "description" => "<UILabel: 0x15f78910; frame = (138.5 3; 43.5 16); text = 'EUROPE'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x15f789d0>>",
              "label" => "EUROPE",
              "alpha" => 1,
              "class" => "UILabel",
              "frame" => {
                 "y" => 3,
             "width" => 43.5,
                 "x" => 138.5,
            "height" => 16
        }
    }
]
touch("view {text BEGINSWITH 'EUROPE'}")
[
    [0] {
               "text" => "EUROPE",
            "enabled" => true,
               "rect" => {
            "center_x" => 160.25,
                   "y" => 396,
               "width" => 43.5,
                   "x" => 138.5,
            "center_y" => 404,
              "height" => 16
        },
                 "id" => nil,
        "description" => "<UILabel: 0x15f78910; frame = (138.5 3; 43.5 16); text = 'EUROPE'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x15f789d0>>",
              "label" => "EUROPE",
              "alpha" => 1,
              "class" => "UILabel",
              "frame" => {
                 "y" => 3,
             "width" => 43.5,
                 "x" => 138.5,
            "height" => 16
        }
    }
]
touch("view {text CONTAINS 'EUROPE'}")
[
    [0] {
               "text" => "EUROPE",
            "enabled" => true,
               "rect" => {
            "center_x" => 160.25,
                   "y" => 396,
               "width" => 43.5,
                   "x" => 138.5,
            "center_y" => 404,
              "height" => 16
        },
                 "id" => nil,
        "description" => "<UILabel: 0x15f78910; frame = (138.5 3; 43.5 16); text = 'EUROPE'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x15f789d0>>",
              "label" => "EUROPE",
              "alpha" => 1,
              "class" => "UILabel",
              "frame" => {
                 "y" => 3,
             "width" => 43.5,
                 "x" => 138.5,
            "height" => 16
        }
    }
]

Swipe the table view cell

for left direction move:

swipe(:left,{:query => "UITableView index:0 tableViewCell indexPath:0,3"})

here 0 refer to row and 3 section

You hav to try with different combination like 0,1 or 0,2


for right direction move:

swipe(:right,{:query => "UITableView index:0 tableViewCell indexPath:0,3"})

here 0 refer to row and 3 section

You hav to try with different combination like 0,1 or 0,2


Swipe using two fingers



def swipeDirectionTwoFingers(text)

if text.eql?("left") 



uia('target.dragInsideWithOptions({touchCount:2, startOffset:{x:1.0, y:0.1}, endOffset:{x:0.1, y:0.1}, duration:1.5})')


end

if text.eql?("right")

uia('target.dragInsideWithOptions({touchCount:2, startOffset:{x:0.1, y:0.1}, endOffset:{x:1.0, y:0.1}, duration:1.5})')

end


end



query("* marked:'1d' parent * index:0",:backgroundColor)


if you discover that an element uses the class UIView, you can click in correspondent class and discover the list of attributes/properties that you can search for. Example:
- :backgroundColor
- :hidden
- :alpha
- :opaque
- :maskView
- :layer
- :accessibilityLabel
In Android the Views (also the TextView) can have almost anything as a background not just a color (a bitmap, a shape, a gradient color, etc). Because of this there is no way to get the background color of a view (it is not stored).
There is a simple form of specifying classes. For example, if you just write button this matches all views which have a class with simple name “button” (or “Button” as this is case in-sensitive). Remember that the simple name of a class is the last segment of the fully qualified class name, e.g., for android.widget.Button it is Button
This is not a limitation of Calabash but the Android system. You can get any property of an Android view if it is accessible.
The property names map to “getter”-methods of the view objects. In general prop:valwill try to call:
  • prop()
  • getProp()
  • isProp()
You can query the following colors on the TextView (nothing is background):
- text color :currentTextColor
- hintTextColor :hintTextColor
- highlight color :highlightColor
- shadow color :shadowColor
You can identifying the properties of the class if you open the project and open the class file that you want to know the attributes. There you can find the properties that you can filter with calabash too.
- Examples:
Radio:
query("RadioButton id:'radio_male'",:setChecked=>true)
query("RadioButton id:'radio_male'",:setChecked=>0)
Check:
query("CheckBox id:'check_update'",:isChecked)
query("CheckBox id:'check_update'",:isChecked=>1)
query("CheckBox id:'check_update'",:checked)
query("CheckBox id:'check_update'",:setChecked=>true)

Progress Bar:
query("RatingBar",setProgress:4)
query("RatingBar",:setProgress=>4)
query("RatingBar",:getProgress)
query("RatingBar",:method_name=>'getProgress', :arguments=>[])
query("RatingBar",:method_name=>'setProgress', :arguments=>[5])
Date:
query("datePicker",:method_name =>'updateDate',:arguments =>[1990,11,30])
Text:
query("EditText id:'email_input'",:getText)
query("EditText id:'email_input'",:text)
query("EditTextid:'email_input'", :method_name=>'setText',:arguments=>['test@test.com'])
query("EditTextid:'email_input'", :method_name=>'getText',:arguments=>[])

indexPath: A special construct that supports selecting cells in UITableViews by index path. The general form is:
"tableViewCell indexPath:row,sec"
where row is an number describing the row of the cell, and sec is a number describing its section.
In general, you can filter on any selector which returns a simple result like a number, string or BOOL.
"button isEnabled:1"
iOS Directions:
There are four directions descendant, child, parent and sibling. These determines the direction in which search proceeds.
Both descendant and child looks for subviews inside a view. The difference is that descendant keep searching down in the sub-view’s subviews, whereas child only looks down one level. The direction sibling searches for views that are “at the same level” as the present view (this is the same as: first find the immediate parent, then find all subviews except for the view itself).By default the direction is descendant, which intuitively means “search amongst all subviews (or sub-views of sub-views, etc).” But you can change the traversal direction. Here is an advanced example:

query("label marked:'Tears in Heaven' parent tableViewCell descendant tableViewCellReorderControl")



Monday, 22 September 2014

INSTALL IDEVICEINSTALLER ON MAC MACHINE

ideviceinstaller

ideviceinstaller is a tool to interact with the installation_proxy of an iOS device allowing to install, upgrade, uninstall, archive, restore, and enumerate installed or archived apps.

1     Software Requirement
1. Homebrew
Refer the previous post for installation of homebrew
http://testeverythingqtp.blogspot.in/2014/09/mobile-webapplication-automation.html
1.1 Install HomeBrew 1. Homebrew, “the missing package manager for OS X,” allows you to easily install hundreds of open-source tools. The full instructions are available on the Homebrew Wiki, but you should only need to run the command that’s listed at the bottom of the Homebrew site:
       $ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
2.       Once the installation is successful, run the following command:
$ brew doctor

Install ideviceinstaller

Open the terminal and type following commands
       $ brew uninstall ideviceinstaller     
      $ brew install --HEAD ideviceinstaller

MOBILE WEB/APPLICATION AUTOMATION INSTALLATION GUIDE FOR IOS

1      Software Requirement

1.       Xcode 5.0 + (Mandatory for iOS 7)
2.       rvm
3.       Ruby 2.0.0
4.       Homebrew
5.       Java
6.       Maven
7.       Ant
8.       Cocoapods
Note: In mac machine, you must have admin rights.

1.1            Install Xcode

Download the latest Xcode from apple developer site

1.2            Install RVM

                           1. Open the terminal window on mac

                          $ \curl -sSL https://get.rvm.io | bash -s stable
                         
                           refer the below url for more info
                                http://rvm.io/rvm/install

1.3            Install RUBY

1.   Ruby is installed by default on Mac, just make sure it is using the version 2.0.0, ruby version can be checked using command;
                                          $ ruby -v
2.   To install ruby version 1.9.2 type below command in terminal
                                          $ rvm install 1.9.2

3.   Once the installation has completed, we need to tell RVM which version of Ruby we currently want to use:
       $ rvm use 1.9.2


                         4.    Make 1.9.2 the Default If you restart Terminal, and type ruby -v again, you'll likely find that it has defaulted back to the system version of Ruby: 1.8.7. That's no good! Let's be sure to make 1.9.2 the default.

rvm --default use 1.9.2

1.4            Install HomeBrew

1.        Homebrew, “the missing package manager for OS X,” allows you to easily install hundreds of open-source tools. The full instructions are available on the Homebrew Wiki, but you should only need to run the command that’s listed at the bottom of the Homebrew site:




                              2.       Once the installation is successful, run the following command:

$ brew doctor

1.5            Install Java, Maven & Ant

1.    Download java .dmg file from http://www.java.com/en/download/
2.    Double click .dmg file and install java
3.    Now download maven from http://www.interior-dsgn.com/apache/maven/maven-3/3.2.1/binaries/apache-maven-3.2.1-bin.tar.gz
4.    Extract maven to any directory
5.    Now to set the environment variables, in the terminal type
$ nano ~/.bash_profile
For Java enter;
      export JAVA_HOME= <path to your java directory >
For Maven enter;
      export M2_HOME= <path to your extracted maven directory>
      export M2=$M2_HOME/bin



Once done press ctrl+O and press enter, now press ctrl+x
6.    In the same terminal enter command
$ source ~/.bash_profile
7.    To install Ant use command
 $ brew install ant
8.    To verify the Maven installation, in terminal, issue the command mvn -version.

$ mvn -version

Apache Maven 3.0.3 (r1075438; 2011-03-01 01:31:09+0800)
Maven home: /usr/share/maven
Java version: 1.6.0_33, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.7.4", arch: "x86_64", family: "mac"
9.    To verify java installation, in terminal, issue the command mvn -version.


$ java -version

How to handle login pop up window using Selenium WebDriver?

Hi All,

Some times while using webdriver we have to face login popup handle.  When we passing the url using webdriver.get or webdriver.navigate.to("URL") at this time browser asks for login credentials.
For handle this situation we have to do following things.

1. HTTP Basic Authentication with Selenium WebDriver

the authentication prompt is not available from the Selenium WebDriver. One of the way to handle this limitation is to pass user and password in the url like like below:


         http://username:password@the-site.com
So just to make it more clear. The username is username password is password and the rest is usual URL of your test web

        WebDriver driver = getDriver();
        String URL = "http://" + username + ":" + password + "@" + "link";
        driver.get(URL);
but sometimes it does not work for IE browser
 we can use robot  method


import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;

import org.openqa.selenium.Alert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;


public class FillAuthAlert {
 private static final String MY_URL = "https://myurl.com";
 private static final String USERNAME= "myuser";
 private static final String PASSWORD= "mypass";
 
 public static void main(String[] args) throws Exception {

  WebDriver driver = new FirefoxDriver();
  driver.get(MY_URL);
  Alert alert = driver.switchTo().alert();
  Robot robot = new Robot();
  Thread.sleep(1000);
  type(robot, USERNAME);
  robot.keyPress(KeyEvent.VK_TAB);
  robot.keyRelease(KeyEvent.VK_TAB);
  Thread.sleep(1000);
  type(robot, PASSWORD);
  alert.accept();
 }
 
 public static void type(Robot robot, String characters) {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        StringSelection stringSelection = new StringSelection( characters );
        clipboard.setContents(stringSelection, null);

        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_V);
        robot.keyRelease(KeyEvent.VK_V);
        robot.keyRelease(KeyEvent.VK_CONTROL);
    }
}

Monday, 20 May 2013

Create issue in JIRA using Http Client via REST API services/ from JAVA



JIRA is a well known Software-suite. In short, JIRA is a proprietary issue tracking product, maintained and developed by Atlassian. It is commonly used for bug tracking, issue tracking, and project management



The JIRA Remote API Calls


I was surprised how easy it was to get the Remote API up and running. Basically you just enable the ‘Accept remote API calls’ option in your General Configuration settings under the Administration tab. The moment you turn it on, the following URL should give you a nice response


Note: It supports only in JIRA >5.0.

Here in am using http client 4.1.2

Here is  the code:

import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.util.EntityUtils;

public class CreateIssue {

 public static void main(String[] args) throws Exception {
  CreateIssue.CreateIssueJira();
 }
public static void CreateIssueJira() throws ClientProtocolException,
   IOException {
  String host = "https://rajivkumarnandvani.atlassian.net/";
  // int port = 8080;
  String userName = "EnterUserName";
  String password = "EnterPassword";
  String ResponseData;
  DefaultHttpClient httpClient = new DefaultHttpClient();
  String jsonObj = "{"
    + "\"fields\": {"
    + "\"project\":"
    + "{"
    + "\"key\": \"DEMO\""
    + "},"
    + "\"summary\": \"REST ye merry gentlemen.\","
    + "\"description\": \"Creating of an issue using project keys and issue type names using the REST API\","
    + "\"issuetype\": {" + "\"name\": \"Bug\"" + "}" + "}" + "}";

  HttpHost targetHost = new HttpHost("rajivkumarnandvani.atlassian.net",
    -1, "https");

  httpClient.getCredentialsProvider().setCredentials(
    new AuthScope(targetHost.getHostName(), targetHost.getPort(),
      targetHost.getSchemeName()),
    new UsernamePasswordCredentials(userName, password));

  HttpPost httpPost = new HttpPost(
    "https://rajivkumarnandvani.atlassian.net/rest/api/2/issue/");
  StringEntity entity = new StringEntity(jsonObj);
  entity.setContentType("application/json");
  httpPost.setEntity(entity);

  // Create AuthCache instance
  AuthCache authCache = new BasicAuthCache();
  // Generate BASIC scheme object and add it to the local auth cache
  BasicScheme basicAuth = new BasicScheme();

  authCache.put(targetHost, basicAuth);

  // Add AuthCache to the execution context
  BasicHttpContext localcontext = new BasicHttpContext();
  localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);

  try {

   HttpResponse httpResponse = httpClient.execute(httpPost,
     localcontext);
   HttpEntity entitydata = httpResponse.getEntity();
   ResponseData = new String(EntityUtils.toByteArray(entitydata));
   System.out.println(ResponseData);
  } catch (ClientProtocolException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
  httpClient.getConnectionManager().shutdown();
 }
}




Thursday, 17 January 2013

Jmeter bean shell script, create file, read jmeter variable value, store script variable value into jmeter variable

Hi All,

Some times in JMeter scripting we need to store the output value in file or wanna show the run time  variable value in console window. OR we need to get the current JMeter script directory path. This can be achieved via scripting in Bean Shell Pre/Post Processor.

Here I am using time and counter function of JMeter to create the file.In bean shell scripting we are reading the JMeter variables value and storing script variable value into JMeter variable or creating Jmeter variable

Here is the  Bean Shell script :

import org.apache.jmeter.services.FileServer;
import org.apache.jmeter.services.FileServer;
import java.util.Date;
import java.text.SimpleDateFormat;

SimpleDateFormat formatter = new SimpleDateFormat( "yyyyMMddHHmmss" );  
String datetime = formatter.format( new java.util.Date() ); 

// Get current running counter value(C refrence name deifned in counter config element)

String counter= vars.get("C");

// Get Jmeter variable value in bean shell script by vars.get method

String timer= vars.get("JmeterTimerVariable");

// here JmeterTimerVariable defined in User Defined variable  config element


//  Display value in Console 

System.out.println("Current counter value = " + counter);

System.out.println("JmeterTimerVariable value = " + timer);


// Store beanshel script variable into Jmeter variable by using vars.put method and we will user this jmetervariable in Wikisearch http request

vars.put("JmeterSearchVariable",datetime+counter);

// get JmeterSearchVariable value in beanshell script

String SearchVariable = vars.get("JmeterSearchVariable");

System.out.println("SearchVariable value = " + SearchVariable);

// Here we can get the directory path of Jmeter script file

String DirPath = FileServer.getFileServer().getBaseDir();

// write into jmeter.log file under Jmeter/bin directory

log.info(DirPath);

System.out.println("Directory path of Jmeter script file = " + FileServer.getFileServer().getBaseDir());

// we will create a file under directory of jmeter script file with name JmeterReords using File system True file will be created if not and data will //append into the file False will create a new file with fresh data

f = new FileOutputStream(FileServer.getFileServer().getBaseDir()+"\\JmeterReords.txt", true); 
p = new PrintStream(f); 
// write data into file 
p.println("Current counter value = " + counter);
p.println("JmeterTimerVariable value = " + timer);
p.println("Directory path of Jmeter script file = " +DirPath);
p.close();
f.close();

// if you want to create unique file for each loop counter refer below script

String uniquefilename = timer+counter;
f = new FileOutputStream(FileServer.getFileServer().getBaseDir()+"\\"+uniquefilename+".log", true); 
p = new PrintStream(f); 
// write data into file 
p.println("Current counter value = " + counter);
p.println("JmeterTimerVariable value = " + timer);
p.println("Directory path of Jmeter script file = " +DirPath);
p.close();
f.close();





Here is the structure of JMeter script

Jmeter Bean Shell script
Jmeter bean Shell script


Wednesday, 9 January 2013

Perform Mouse, drag-and-drop, sliding, selecting multiple Action in Webdriver/Selenium 2

Perform Mouse, drag-and-drop, sliding, selecting multiple Actions in Web driver/Selenium 2 

Solution

The example code below shows some examples where we can use the Actions interface of Selenium WebDriver.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package selenium2.examples;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class ActionExample {
    private static WebDriver driver;

    @BeforeClass
    public void setUp() {
        driver = new FirefoxDriver();
    }

    @AfterClass
    public void tearDown() {
        driver.close();
        driver.quit();
    }

    @Test
    public void draggable() {
        driver.get("http://jqueryui.com/demos/draggable/");

        WebElement draggable = driver.findElement(By.id("draggable"));
        new Actions(driver).dragAndDropBy(draggable, 120, 120).build()
                .perform();
    }

    @Test
    public void droppable() {
        driver.get("http://jqueryui.com/demos/droppable/");

        WebElement draggable = driver.findElement(By.id("draggable"));
        WebElement droppable = driver.findElement(By.id("droppable"));
        new Actions(driver).dragAndDrop(draggable, droppable).build().perform();
    }

    @Test
    public void selectMultiple() throws InterruptedException {
        driver.get("http://jqueryui.com/demos/selectable/");

        List<WebElement> listItems = driver.findElements(By
                .cssSelector("ol#selectable *"));

        Actions builder = new Actions(driver);
        builder.clickAndHold(listItems.get(1)).clickAndHold(listItems.get(2))
                .click();

        Action selectMultiple = builder.build();
        selectMultiple.perform();
    }

    @Test
    public void sliding() {
        driver.get("http://jqueryui.com/demos/slider/");

        WebElement draggable = driver.findElement(By
                .className("ui-slider-handle"));
        new Actions(driver).dragAndDropBy(draggable, 120, 0).build().perform();
    }
}

Translate







Tweet