Selendroid Mobile Gestures

Mobile Gestures

Selendroid is implementing the Advanced User Interactions API. This is a new, more comprehensive API for describing actions a user can perform on an app. This includes actions such as drag and drop or clicking multiple elements while holding down the Control key.

 

Supported Interactions

  • doubleTap(WebElement onElement)
  • down(int x, int y)
  • flick(int xSpeed, int ySpeed)
  • flick(WebElement onElement, int xOffset, int yOffset, int speed)
  • longPress(WebElement onElement)
  • move(int x, int y)
  • singleTap(WebElement onElement)
  • up(int x, int y)

 

Example

How to swipe from right to left

Java:

#Please import: org.openqa.selenium.interactions.touch.TouchActions

WebElement pages = driver.findElement(By.id("vp_pages"));
TouchActions flick = new TouchActions(driver).flick(pages, -100, 0, 0);
flick.perform();

Fonts: http://selendroid.io/gestures.html

My app doesn’t start when I run the command cucumber

Hello guys !

I hope you are fine. I am searching here for a problem that I had for the second time when I tried to run cucumber and calabash in a PC.

First, I got the installation of cucumber framework on the app, but when I run the command: cucumber. The splash screen appears a lot of times, but the app doesn’t start. It seems that the cucumber are trying to open the app and something is blocking.

After you have all configured, this problem won’t happen again. I am trying to reproduce the problem in my PC and since this already is configured the problem didn’t happen again. For this reason I think that it is some permission or update type of problem.

  1. Look on the launch.rb file inside the folder features/support if the line APP_BUNDLE_PATH is commented with # in front of. (Because this just have to be used as the last case if the app doesn’t start). There should generally be no need to set ANY environment variables for default project setups. APP_BUNDLE_PATH should only be set if Calabash is not able to detect it correctly. SDK_VERSION should only be set if you don’t want to run in the latest iOS simulator version. OS should never need to need to be set.
  2. Check if the cucumber is installed in the app:
    calabash-ios check PATH_TO_IPA_OR_APP

     

  3. Disable your firewall: https://groups.google.com/forum/#!msg/calabash-ios/AXrXhGB2_mc/wIzR16Sm2IEJ
  4. Try running with sudo.
  5. Verify if your permission is of admin and what is the user that you is trying to run cucumber (must be the same)
  6. Verify if you have permission to access the page of the project and the .app with the user that you are using to run cucumber
  7. Have you built the -cal target from XCode?
  8. Are you using Xcode5? Have you run sudo xcode-select -switch PATH_TO_XCODE/Content/Developer.When using the final version of Xcode5 you should havexcode-select -print-path
    /Applications/Xcode.app/Contents/Developer➜ ~ instruments
    instruments, version 5.0 (51166)Xcode5 must be installed in the default /Applications/Xcode.app location
  9. Please stop the simulator. Do not start it from Xcode, instead let Calabash launch the simulator.
  10. Make sure you use the iPhone Retina or the iPad simulator. There is a well-known bug with instruments and its ability to launch the iPhone (non-retina simulator).
  11. Try the following – it is the easiest way to test if it is working:In your project folder (typically the folder just above your ‘features’ folder), run:
    DEBUG=1 calabash-ios console
    start_test_server_in_background(:timeout => 30)
    
    

    run_loop.out

    What is the contents of this file? run

    cat /var/folders/…/run_loop.out

     

  12. The password prompt seems to be bogus, as hit cancel still allows calabash to do what it needs to do, and everything works.To resolve the issue, I edited /etc/authorization:
    
               <string>user</string>
    
               <string>rule</string>
               <key>rule</key>
               <array>
                   <string>is-developer</string>
               </array>
    

    This changes system.privilege.taskport, which was using the implicit user rule to ensure the current user was a member of _developer to an explicit rule to do the same. The end security constraints should be identical, and now a password prompt is never shown for calabash. SSH runs work just fine.

    security authorizationdb write system.privilege.taskport is-developer
    
    

     

  13. Try use this command to debug the session and discover what is happening:
    DEBUG=1 calabash-ios console
  14. Start the installation again:
    1. Comment out the APP_BUNDLE_PATH definition on YourProject/features/support/01_launch.rb like #APP_BUNDLE_PATH = "~/..../../myApp-cal.app" so The calabash gem can locate the app automatically.
    2. Open a console go to the project folder from it. Then enter gem install calabash-cucumber this will install the calabash gem its ok to run again even if you installed it previously there’s no harm.
    3. Now open the project file in xcode editor (You can see the calabash.framework added to your project’s framework group successfully.) select the yourApp-cal target and the simulator you want clean, build and run the your App-cal target on your simulator.
    4. Then stop it and come back to that console enter calabash-ios console console will start a ruby console that you can work with the app. now (while simulator is on your screen but your app is backbround on that simulator) type start_test_server_in_background your app must come to foreground. If that works the calabash can find and run your app on simulator.
    5. Remember only if you create an app build on a separate folder using a xcodebuild command or script or something, thats the time to set the APP_BUNDLE_PATH variable.
  15. Look what is the result of these commands:
    # xcode installation location
    $ xcode-select --print-path
    # xcode version
    $ xcodebuild -version
    # calabash version
    $ calabash-ios version
    # calabash.framework version
    # start your app manually in the simulator or from Xcode
    # and then launch a console
    $ calabash-ios console
     server_version
  16. Look if it is enable, running this command:
    DevToolsSecurity -status
  17. Try these steps:
    1. Update gem packages: sudo gem update
    2. Cleanup old gem packages: sudo gem cleanup
    3. Execute “Clean build folder…” in Xcode
    4. Close Xcode and simulator
    5. Delete all folders from /Developer/Xcode/DerivedData
    6. Reboot your computer
    7. Rebuild your project and run the tests
  18. Try reset Simulators:

    killall 'iPhone Simulator'
    rm -rf ~/Library/Application\ Support/iPhone\ Simulator/
  19. You can turn on additional calabash debugging running:
    DEBUG=1 CALABASH_FULL_CONSOLE_OUTPUT=1 calabash-ios console
  20. Connect to calabash-ios console and use query when executing command:
    DEVICE=ipad DEVICE_ENDPOINT=http://xx.xx.xxx.xx:37265 BUNDLE_ID=build/LPSimpleExample-cal DEVICE_TARGET=device calabash-ios console
  21. Follow these steps:
    1. Reboot the device
    2. Make sure you can see the device from XCode “devices” (Cmd-2) and that it is “green”
    3. Make sure the app is installed on the device
    4. Make sure you can run “profile” with automation from xcode
    5. Make sure the device doesn’t have a “autolock passlock code”
    6. Reboot your mac.
  22. Use OS key for OS version, name key for device, key-value options list should be comma separated.
    For example:
    xcodebuild -project ABC.xcodeproj -scheme ABC-cal -destination OS=6.1,name=iPad
  23. Clear the instruments:
    1. Run this command:
      killall -9 instruments
    2. And restart the device sometimes works.
  24. After trying all these things, restart your pc and try again:
    $ SDK_VERSION=6.0 DEVICE_TARGET=simulator DEVICE=iphone cucumber

    (This is the last hope… lol)

Thank you again !

Fonts:

https://groups.google.com/forum/#!msg/calabash-ios/AXrXhGB2_mc/wIzR16Sm2IEJ

https://github.com/calabash/calabash-ios/issues/203

https://github.com/calabash/calabash-ios#important-notice

http://www.gerardcondon.com/blog/2012/10/22/setting-up-calabash-on-ios/

https://groups.google.com/forum/#!topic/calabash-ios/b1f1sVtU0ys

https://github.com/calabash/calabash-ios/wiki/A0-UIAutomation—instruments-problems

https://github.com/calabash/calabash-ios/wiki/01-Getting-started-guide

https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/UsingtheAutomationInstrument/UsingtheAutomationInstrument.html

http://stackoverflow.com/questions/24022823/ios-simulator-doesnt-launch-with-calabash

https://groups.google.com/forum/#!msg/calabash-ios/B3OUOYf7lFY/u8uBYGCOyosJ

https://groups.google.com/forum/#!topic/calabash-ios/ntpNi91DeCE

https://groups.google.com/forum/#!msg/calabash-ios/jfx9CvVoliw/EARXTGYdaFkJ

http://www.marshut.com/uvuzr/calabash-tests-do-not-start-on-iphone-devise-though-application-has-been-started.html

http://www.marshut.com/vutwq/for-people-with-launch-and-ios7-questions.html#imqxmw

http://www.marshut.com/mxzin/instrument-errors-when-trying-to-execute-test-cases-in-device-calabash-9-144.html

 

 

 

What is headless browser ?

Every browser must to do 3 things:

  1. With an address, to access any site
  2. Render the content in DOM, run scripts inside of tag script and turns it able on the page
  3. Render the DOM in a visual content

A browser that do only the first item is called of  “text-based”. A browser that surround the 3 itens is the browsers that we know nowadays. A headless browser surround both firsts itens.

So,  headless browser is a browser that don’t have graphical interface, means: We don’t see the content of the page in our screen, but the browser runs any action on the URL.

What is its function?

Two things: As crawler and as a browser that do faster tests. The rising use of headless browsers is the capacity of run tests a faster way than a browser with graphical interface.

It turns more faster to don’t need load a lot of visual contents, as css styles on elements and load of images.

Think in a Continuous integration, each behaviour(commit, time, version…) a system of CI has to process (compile, unit tests with/or not integration, deploy, acceptance tests). In this process run the tests daily in a environment of CI will spend a lot of time to give us a feedback that we need.

What the people used to do is separate in few parts the most important scripts (smoke, sanity) with known tools (Selenium, Watir, Robot Framework), but these tests still spend a precious time on the execution because of the visual contents that they need.

Other people create scripts or just update them to execute on headless browser. This give to us a huge gain on execution and give to us a more faster feedback.

What are the headless browsers that we can use?

There are a lot of headless browsers on the market and the most part of them (and the best) are open source. They are developed on WebKit and Javascript. The most popular headless browsers:

  • PhantomJS
  • CasperJS
  • SlimerJS (Gecko)
  • HtmlUnit
  • ZombieJS

And Selenium/WebDriver can run tests in the most popular headless browsers:

  • HtmlUnit through of HtmlUnitDriver
  • PhantomJS through of GhostDriver

If you have any doubt or suggestion, just write below !

Thank you again guys 🙂

Implementing cross-browser with Selenium

Hi guys !!

I wrote a simple example of how we can implementing cross browser code.

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

public class CrossBrowsers {

    public WebDriver Select(WebDriver driver) throws IOException, Exception {
        try {
            //Switch browsers
            switch (driver.getBrowser()) {
                case "firefox": {
                    FirefoxProfile profile = new FirefoxProfile();
                    profile.setPreference("network.proxy.type", 0);
                    driver.setDriver(new FirefoxDriver(profile));
                    driver.getEnvironment();
                    break;
                }
                case "ie": {
                    DesiredCapabilities cap = DesiredCapabilities.internetExplorer();
                    Proxy proxy = new Proxy();
                    proxy.setNoProxy(environment);
                    cap.setCapability(CapabilityType.PROXY, proxy);
                    cap.setCapability(
                            InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); 
                    cap.setCapability("ignoreZoomSetting", true);
                    cap.setCapability("ignoreProtectedModeSettings" , true);
                    cap.setCapability("initialBrowserUrl", driver.getEnvironment());
                    File file = new File("drivers//IEDriverServer.exe");
                    System.setProperty("webdriver.ie.driver", file.getCanonicalPath());
                    driver.setDriver(new InternetExplorerDriver(cap));
                    driver.get(environment);                    
                    break;
                }
                case "chrome": {
                    DesiredCapabilities cap = DesiredCapabilities.chrome();
                    Proxy proxy = new Proxy();
                    proxy.setNoProxy(driver.getEnvironment());
                    cap.setCapability(CapabilityType.PROXY, proxy);
                    cap.setCapability("chrome.switches", Arrays.asList("--disable-web-security"));
                    cap.setCapability("chrome.switches", Arrays.asList("--safebrowsing-disable-download-protection"));
                    cap.setCapability("chrome.switches", Arrays.asList("--ignore-certificate-errors"));
                    File file = new File("drivers//chromedriver.exe");
                    System.setProperty("webdriver.chrome.driver", file.getCanonicalPath());
                    driver.setDriver(new ChromeDriver(cap));
                    driver.getEnvironment();
                    break;
                }
            }
        } catch (IOException ex) {
            System.print.out(ex);
        }
        return driver;
    }
}

If you have any question or suggestion, please just write below on the comments.

Have a nice week everyone, Bye !!

JMeter Distributed Testing Step-by-step

Hi guys, I found this tutorial about Jmeter distributing testing in different PCS. This short tutorial explains how to use multiple systems to perform stress testing. Before we start, there are a couple of things to check.

  1. the firewalls on the systems are turned off.
  2. all the clients are on the same subnet.
  3. the server is in the same subnet, if 192.x.x.x or 10.x.x.x ip addresses are used. If the server doesn’t use 192 or 10 ip address, there shouldn’t be any problems.
  4. Make sure JMeter can access the server.
  5. Make sure you use the same version of JMeter on all the systems. Mixing versions may not work correctly.

Once you’ve made sure the systems are ready, it’s time to setup remote testing. The tutorial assumes you already have JMeter installed on all the systems. The way JMeter works is 1 master controller initiates the test on multiple slave systems.

1

Terminology
Before we dive into the step-by-step instructions, it’s a good idea to define the terms and make sure the definition is clear.
Master – the system running Jmeter GUI, which controls the test
Slave – the system running jmeter-server, which takes commands from the GUI and send requests to the target system(s)
Target – the webserver we plan to stress test
2
Step-by-Step

  1. On the slave systems, go to jmeter/bin directory and execute jmeter-server.bat (jmeter-server on unix). On windows, you should see a dos window appear with “jre\[version]\bin\rmiregistry.exe”. If this doesn’t happen, it means either the environment settings are not right, or there are multiple JRE installed on the system. Note: [version] would be the jre version installed on the system.
  2. Open jmeter-server.bat in a text editor
  3. go to line 44 and find “:setCP”
  4. edit “START rmiregistry” to the full path. Example: “START C:\<JAVA_HOME>\jre\bin\rmiregistry”
  5. On master system acting as the console, open windows explorer and go to jmeter/bin directory
  6. open jmeter.properties in a text editor
  7. edit the line “remote_hosts=127.0.0.1”
  8. add the IP address. For example, if I have jmeter server running on 192.168.0.10, 11, 12, 13, and 14, the entry would like like this: remote_hosts=192.168.0.10,192.168.0.11,192.168.0.12,192.168.0.13,192.168.0.14
  9. Start jmeter.
  10. Open the test plan you want to use
3
Starting the Test
At this point, you are ready to start load testing. If you want to double check the slave systems are working, open jmeter.log in notepad. You should see the following in the log.
Jmeter.engine.Remote
JMeterEngineImpl:
Starting backing engine
If you do not see this message, it means jmeter-server did not start correctly. For tips on debugging the issue, go to the tips section. There are two ways to initiate the test: a single system and all systems.
Start a single clients
4
  1. click Run at the top
  2. select Remote start
  3. select the IP address

 

Start all clients

5
  1. click Run at the top
  2. select Remote start all or use CRTL-Z

 

Limitations

There are some basic limitations for distributed testing. Here’s the list of the known items in no specific order.

  1. RMI cannot communicate across subnets without a proxy; therefore neither can jmeter without a proxy.
  2. Since JMeter sends all the test results to the controlling console, it is easy to saturate the network IO. It is a good idea to use the simple data writer to save the results and view the file later with one of the graph listeners.
  3. Unless the server is a large multi processor system, in most cases

 

Tips

In some cases, the firewall may still be blocking RMI traffic. Symantec Anti Virus and Firewall. In some cases, Symantec firewall needs to be stopped from windows services.

  1. open control panel
  2. open administrative tools
  3. double click services
  4. Go to down to symantec anti virus, right click and select stop

Windows firewall

  1. open network connections
  2. select the network connection
  3. right click and select properties
  4. select advanced tab
  5. uncheck internet connection firewall

Linux

On Suse linux, ipchains is turned on by default. For instructions, please refer to the “remote testing” in the user manual.

On RedHat (or derivatives), iptables (netfilter) is turned on by default. Execute “service iptables stop” to stop the Linux netfilter firewall.

 

Fonts: http://wiki.apache.org/jmeter/JMeterFAQ#How_to_do_remote_testing_the_.27proper_way.27.3F

http://jmeter.apache.org/usermanual/remote-test.html

http://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.pdf

Interview’s Logic Tests

Yes Guys !

I will write a post about this, because recently I made some logic tests that are VERY VERY easy, but because of my nervous I made some mistakes :/ Really, I have to stop to stay anxious about something… So, let’s go:

Tests Fibonnaci – JAVA:

package Tests;
public class Main {
    static long fibo(int n) {
       if (n < 2) {
          return n;
else {
          return fibo(n – 1) + fibo(n – 2);
}
}
public static void main(String[] args) { // test
        for (int i = 0; i < 15; i++) {
System.out.print(Main.fibo(i) + “\t”);
}
}
}

Tests Reverse String – JAVA:

package Tests;


public class Main {

    static String converse() {
        String a = "This is a string...";
        String b = "";

        for (int i = a.length() - 1; i >= 0; i--) {
            b = b + a.charAt(i);
        }
        return b;
    }

    public static void main(String[] args) { // test 
      System.out.println(Main.converse());

    }
}

JMeter Setup on Mac

In summary, this initial setup will create a way for you to record all of the requests that get made when using your web-application. From here, you can save certain thread sets and run tests where multiple instances of these thread-sets are sent to your web app.

My plan is to use this to record what Selenium does, and then use that for load testing. If I use Selenium IDE to make the aforementioned Selenium routines, the redundancy is hilarious. But in all seriousness, I am really excited to pair the two of them together. I am a bit worried though about whether JMeter can keep up with Selenium…
What I am wondering is ‘What benefit is there to using JMeter over Fiddler?’… probably has to do with being able to integrate JUnit tests etc more easily… but I don’t know. Any comments?
First: Installation

  1. Download JMeter. You may download the source code and build it yourself, or you may download the binaries. I just downloaded the binaries.
  2. While on the JMeter Download page, follow the instructions provided to verify the md5 (Mac OSX Snow Leopard Server does not come with pgp, gpg, or pgpk.)
    • In Terminal.app
      • md5 jakarta-jmeter-2.5.1.zip
    • Click ‘md5’ next to the version of JMeter you downloaded. There will be a 20 character value shown, and it should match what you got in the the terminal. A quick way to check this is to just use ⌘+F in your browser and copy in your results from the terminal. 
  3. In your Finder, uncompress jakarta-jmeter-2.5.1, and drill down into the directory called ‘bin’.
  4. Open ApacheJMeter.jar
    • If you prefer the Terminal, use the following:
    • sh ./jakarta-jmeter-2.5.1/bin/jmeter.sh
Setup & Tuning-in to your web-browser
  1. Add (via right click) a Thread group to the Test Plan 1
  2. Add a Non Test Element > HTTP Proxy Server to the Workbench 2
  3. Open the HTTP Proxy Server Page and change the port if required 3
  4. Set the Target Controller to Test Plan > Thread Group on the same page 4
  5. Configure your browser to use the Proxy Server (it’s localhost) 5
    1. Zac Spitzer recommends Firefox. This is probably the case because you can set up proxying internally to Firefox without messing around with your system settings. If you try to go ‘Under the Hood’ in Chrome or into Safari’s ‘Change Settings…’ dialog, it will kick you right into your system preferences. Please note that if your workplace has a special proxy configuration already, or any other network settings that might interfere with setting this up, don’t fight it: submit a ticket to IT. 
      1. ⌘+,
      2. In ‘Advanced’, go to your connection settings and set up your localhost as a proxy server. You can assign different ports to different protocols. 
  6. Press Start at the bottom of the page 6

Now, JMeter will record all the HTTP requests your browser makes, so make sure you have closed all the other tabs you have open. 7

Don’t forget to reset your browser proxy settings! 8

You can delete any requests you don’t want from the list at any time. 9

Remember to read the documentation and be careful! Make sure you know what servers will be affected by your testing, and don’t jump to simple conclusions, 3-tier web apps are complex beasts. 10

What is cross-browser ? Why I have to perform it ?

Nowadays, we have to test our application in a lot of browsers, but how ?

Cross-browser testing is chose to guarantee that a website or web application works on different browsers and it involves compatibility check and testing of both client-side apps.

According to the statistics from W3Schools, Chrome is one of the most popular browsers these days with 54.1% market share followed by Firefox with 27.2% market share. On the other hand Internet explorer is at third place with 11.7% market share followed by Safari and Opera.

10268702_801134233233224_3463662876642180326_n

Maybe your website will look very different in all these browsers as each of the browsers will understand some code a little differently than the other one. For this reason, it is important to perform cross-browser testing to ensure your website runs on all the mainly browsers.

Reasons to test your website in other browser:

-Running browser specific tests will spend more time.

-Customers never like to use the same browser.

-Mobile is in demand. Pay attention in mobile browsers.

-New technology is not supported by all browsers.

-You have to worry with the Security too.

-No one likes to maintain separate tests for each and every browser. (Of course, it is boring)

 

Browser Compatibility?

Check whether the application works the way it should across all the browsers, you should take a look at the following ingredients of a web application or website:

-HTML:

– CSS Styles & CSS Validations:

– Sessions & Cookies:

-JavaScript:

– Text Alignments & Page Layouts:

There are several other important areas of web applications to be considered for achieving 100% cross-browser compatibility such as:

-Font Sizes
-Mouse Hover
-SSL Certificates
-Upload File
-Export File
-Scroll Bar Appearance
-Flash Work
-Page Zoom In/Out
-Pop Ups
-Space between various HTML components, etc.

Functional Testing?

> There are 5 actively used versions of Internet Explorer, 8 versions of Firefox, 7 versions of Chrome, 3 versions of Safari and 3 versions of Opera. That makes a total of 26 versions of browsers on which to test your application.

> Even if you cut down to the main versions of each of the main browsers, you will have to repeat your web application testing at least 9 times.

> You need to test your application on multiple browser versions every time your application has a new release.

> You need to test your application on multiple browser versions every time the browser has a new release. Firefox releases a new version almost every 2 weeks.

> Manual testing on each browser version is time consuming, monotonous and prone to human errors.