Commands to use running Cucumber

Hi guys, I am writing here the commands to use when you run cucumber on Automation. It is very usefully 🙂

Launching and Customizing launch

Calabash has two ways of launching apps: SimLauncher and Apple’s instruments tool. Each has its own advantages and problems (see below).

For iOS7+ only the instruments launch method is supported. If instruments is not used to automatically launch the app touch events wont work.

Since version 0.9.154, Calabash is using instruments and UIAutomation to launch apps by default. The primary reason for this is two-fold: (a) in iOS7, Apple removed access to APIs previously used to synthesize touch events and we needed a different approach, (b) there are things possible with UIA that are not possible from “inside the app”, i.e., in the Calabash server (like accepting the Access to current location dialog or sending the app to the background).

The launch method can be controlled using environment variables. With Calabash 0.9.157+, the use of environment variables was greatly simplified. If you’re updating from a previous version, it is recommended to try removing all the environment variables, and then adding only the ones you’re sure you need.

  • DEVICE_TARGET controls which device to launch on. When set Calabash uses instruments to launch. The default is ‘simulator’ (see also Testing on Physical iDevices). You can also setDEVICE_TARGET=device or DEVICE_TARGET=UDID_OF_CONNECTED_DEVICE to pick a specific connected device, or DEVICE_TARGET=simulator to force use of instruments and simulator. (You can see the UDID of your device in the Devices tab in Xcode’s Organizer window).
  • SDK_VERSION is only used when running on the simulator. It controls which iOS version of the simulator is launched. Note, SDK_VERSION forces the launch method to be SimLauncher (not instruments). The reason for this is that the instruments tool does not support launching a simulator that is not the latest version.
  • DEVICE=ipad if you want to ensure we launch the iPad simulator. Defaults to ‘iphone’.
  • OS is deprecated and now automatically detected (it was previously used to decide which “recordings” to use for playback).
  • NO_LAUNCH is not supported when running with instruments. It tells Calabash to not automatically launch the app (it is mostly used when you want to start the app yourself – should rarely be used).
  • NO_STOP means don’t stop the app after the test completes. (It is mostly used to leave the app open in case of a test failure and should be used for debugging purposes only).
  • RESET_BETWEEN_SCENARIOS (example: RESET_BETWEEN_SCENARIOS=1) – Reset iOS Simulator between each scenario.

EG.

$ SDK_VERSION=6.1 DEVICE=ipad cucumber 

Explore interactively!

To start-up a console, you can run the command: calabash-ios console and then start a simulator withstart_test_server_in_background for iOS7 to get touch events to work.

Try starting your app using the -cal scheme from Xcode and then run calabash-ios console. This will give you a Calabash console (it is just a Ruby irb with calabash loaded).

From this console you can explore your application interactively.

You can query, touch, scroll, etc from the irb session. This information below also serves as an introduction for the APIs that are available in other place.

Query

If your app have two buttons. Try this from the console:

irb > query("button") 

You should see something like this:

=> [{"class"=>"UIRoundedRectButton", frame"=>
{"y"=>287, "width"=>72, "x"=>100, 
"height"=>37}, "UIType"=>"UIControl", 
"description"=>"<UIRoundedRectButton: 0x7d463d0; 
frame = (100 287; 72 37); opaque = NO; autoresize = RM+BM;
 layer = <CALayer: 0x7d46ae0>>"}, 
{"class"=>"UIRoundedRectButton", "frame"=>
{"y"=>215, "width"=>73, "x"=>109, 
"height"=>37}, "UIType"=>"UIControl", 
"description"=>"<UIRoundedRectButton: 0x7d3a760; 
frame = (109 215; 73 37); opaque = NO; autoresize = RM+BM;
 layer = <CALayer: 0x7d3a8a0>>"}] 

This is actually an array with two objects that are descriptions of the two buttons. For example, the class of the first button is “UIRoundedRectButton”. We can dive into this information using Ruby programming:

irb > result = query("button") ... irb > btn1 = 
result[0] ... irb > class1 = btn1["class"] => 
"UIRoundedRectButton" 

The query function takes a string query as an argument. The query argument is similar to a css selector, for example we can do:

irb > query("button index:0 label") => 
[{"class"=>"UIButtonLabel", "frame"=>{"y"=>9, 
"width"=>38, "x"=>17, "height"=>19}, "UIType"=>"UIView", 
"description"=>"<UIButtonLabel: 0x7d41120; frame = 
(17 9; 38 19); text = 'other'; clipsToBounds = YES; opaque 
= NO; userInteractionEnabled = NO; layer = <CALayer: 
0x7d40510>>"}] 

This means “find the first button, and then inside of that find all labels”.

Query may also take parameters that are mapped to Objective-C selectors on the found object.

irb > query("button index:0 label", :text) => 
["other"] 

Query is very powerful, but the full syntax and power of query is beyond the scope of the Getting started guide on GitHub.

Touch

Anything that can be found using query can also be touched. Try this while you watch the iOS Simulator:

irb > touch("button index:0") 

Notice that the button is touched (turns blue), although this button doesn’t do anything.

You can also touch the tab bars:

irb > touch("tabBarButton index:1") 

The filter: index:1 means that it is the second tab-bar button that should be touched.

Setting accessibility

Identifiers and accessibility

Labels

In general UI views are found using accessibility ids or labels. Go to the “First” tab in simulator, and then in your console session try this:

# query for the switch on the "First" tab irb > 
query("view marked:'switch'") [ [0] { "class" => 
"UISwitch", "frame" => { "y" => 148, "width" => 
79, "x" => 106, "height" => 27 }, "UIType" => 
"UIControl", "description" => "<UISwitch: 0x7d3ffb0; 
frame = (106 148; 79 27); <snip> >>" } ] 

You can set the accessibility attributes of UIView from the Interface Builder or programmatically.

In some cases the UIKit framework will set the accessibilityLabel for you if you don’t explicitly set the value.

For example, UITabBarButton will have an accessibility label that is the same as title of the tab bar button.

irb > query("tabBarButton marked:'Second'") [ [0] {
 "class" => "UITabBarButton", "id" => nil, "rect" 
=> { "center_x" => 120, "y" => 520, "width" =>
 76, "x" => 82, "center_y" => 544, "height" => 48 
}, "frame" => { "y" => 1, "width" => 76, "x" =>
 82, "height" => 48 }, "label" => "Second", 
"description" => "<UITabBarButton: 0x857e010; frame = 
(82 1; 76 48); <snip> >" } ] 

Whenever possible, you should use the accessibilityIdentifier of UIView and reserve the accessibilityLabel for providing localized Accessibility traits.

- (void) viewDidLoad { [super viewDidLoad]; UISwitch 
*switch = self.wantsCoffeeSwitch; # ex. queries # query 
"view marked:'wants coffee'" # query "switch 
{accessibilityIdentifier LIKE 'wants coffee'}" # query 
"switch marked:'wants coffee'" 
switch.accessibilityIdentifier = @"wants coffee"; # 
accessibilityLabels should be localized and follow the 
conventions # described by Apple's Accessibility 
documentation if (switch.isOn == YES) { 
switch.accessibilityLabel = NSLocalizedString(@"Wants 
coffee"); } else { switch.accessibilityLabel = 
NSLocalizedString(@"Does not want coffee"); } } 

 

Thank you guys ! If you have any question, just write below. Bye !!
Fonts: https://github.com/calabash/calabash-ios/wiki/01-Getting-started-guide

TestComplete 10.1 Released with Real-Device Support for iOS

Hello guys, I will put today a post about automation tests with TestComplete on mobile apps. I used to work with Cucumber and Calabash, but if you want to try another tool, this is very used too.

The new TestComplete 10.1 release now supports real-device test automation for iOS applications so you can rest assured that your mobile apps are of the highest quality. In the recent SmartBear study, State of Mobile Testing 2014, 21% of those surveyed told us that app quality was the greatest challenge for success in mobile.

Image

Efficient mobile application testing results in higher quality applications. With a good test automation tool in your toolbox, you can automate tasks like data-driven testing, authentication testing, and functional checks, so your team can focus on more time-intensive application testing that require human interaction.

So what does the new release of TestComplete bring to iOS mobile testing?

  • Real-Device Testing for iOS versions 6 and 7
  • Object Recognition for iOS Applications
  • Multi-Device Testing
  • Device Pools

Native Application Testing

The new release supports testing of native iOS applications without the need to root your devices, including keyword and scripted tests. By using the new Mobile Screen, which replicates your application on your desktop computer as you test, with our Object Browser, you can easily make the connection between screen elements and their associated objects in the code.

Image

Object Recognition

TestComplete 10.1 has full object recognition of tested iOS applications, including object parameters for low-level testing. Use the Name Mapping feature to label objects like grids, buttons, and layers within your mobile app so you can easily identify them in both tests and test results.

By relying on object recognition, your tests are immune to GUI-level changes during the development cycle that can occur when an automation tool relies solely on screen elements.

Image

Multi-Device Testing

By leveraging our object recognition and common controls technology, TestComplete 10.1 ensures that your automated tests are compatible with any Apple device running iOS 6 or 7. This means you can create a test once and run that same test on all of your devices, regardless of screen resolution or aspect ratio.

TestComplete 10.1 also includes a device pool feature that allows you to manage all of the devices in your testing pool. You can start and stop tests on any device from this central pool, allowing you the ultimate flexibility in how, where and when your automated tests run.

This isn’t a free software, but you can try for 30 days.

Bye guys ! This is the other tool very known in the automation market.

Fonts: http://blog.smartbear.com/test-automation/testcomplete-10-1-released-with-real-device-support-for-ios/

Data Driven with Selenium IDE

Ok, I really don’t like of Selenium IDE for many reasons, but today I will show one way to use Data Driven with its. This can help the guys who are beginning on automation.

Here are the steps to follow:

  1. Download the flowcontrol extension for IDE. (“Download” is a bit of a misnomer here, as the download link takes one to an HTML page. Simply copy/paste only the JavaScript contents of that page into a file named goto_sel_ide.js.)
  2. Download the 1.1 version of the includeCommand4IDE extension. (The just-released 1.2 version appears to have a serious bug.)
  3. Download the most recent version (0.2) of the datadriven.js extension.
  4. Install these 3 extensions in IDE via the Selenium Core extensionsfield (accessible via Options=>Options=>General). They must be specified in the order above!!!
  5. Re-start IDE so that all 3 extensions will get read in.
  6. Create an .xml file
    <testdata>
    <test linkText="How It Works" title="Sauce OnDemand: Cross browser testing 
    with hosted Selenium testing in the cloud - Sauce Labs"/>
    <test linkText="Downloads" title="Sauce Labs Downloads"/>
    <test linkText="Pricing" title="Sauce Labs Pricing For Hosted 
    Selenium in the Cloud"/>
    <test linkText="Support" title="Support: Sauce RC (Selenium RC) - 
    Sauce Labs"/>
    <test linkText="Forums" title="Sauce Labs Forums"/>
    <test linkText="Blog" title="Selenium Testing? Do Cross Browser 
    Testing with Sauce Labs"/>
    <test linkText="Flash/Flex Solution" title="Automate testing of your 
    Flex and Flash Web Apps - Sauce Labs"/>
    <test linkText="Documentation" title="Documentation - Sauce Labs"/>
    <test linkText="About" title="About - Sauce Labs"/>
    <test linkText="Team" title="The Sauce Labs Team"/>
    <test linkText="News" title="Selenium News &amp; Events - Sauce Labs"/>
    <test linkText="Webinars" title="Webinars - Sauce Labs"/>
    <test linkText="Contact us" title="Support Contact - Sauce Labs"/>
    <test linkText="Service Status" title="Status - Sauce Labs"/>
    </testdata>
    
  7. linkText and title are variable names of my choosing. You can use any names you want, and also any number of variables you want. The critical thing is that each container must contain all the data–input and output–for a single test case.
  8. View your .xml file in the browser to ensure that it does not contain any errors (only necessary if you did not use an XML editor to create the file).
  9. Utilize your .xml file via creating an HTML test case:
    loadTestData file:///Users/mamp/Desktop/BLOG/saucelabs-footer.xml open 
    http://www.saucelabs.com while !testdata.EOF() nextTestData
    
    clickAndWait link=${linkText} verifyTitle ${title} goBackAndWait endWhile

Be sure to replace the URL for the .xml file provided to loadTestData above with the appropriate URL on your computer.

Run the test.

Thank you guys. Have a good weekend !

 

Fonts: http://saucelabs.com/blog/index.php/2011/01/selenium-resources-for-newbs-data-driven-testing-with-ide-xml/

 

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());

    }
}