Test automation using Selenium SaucePresentation Transcript
Web and Mobile Web Automation using Selenium And Sauce Presented By B.K.Venkata. Uday Kumar
Overview1. Overview of Sauce Cloudified Services2. Usage of Sauce -Interactive Session3. Usage of Sauce –Script Mode4. Integration of Selenium2 and Sauce Services5. About Sauce Connect6. Dashboard –Sauce7. Features of Sauce Cloud8. Advantages & Disadvantages of this Approach9. References
Overview of Sauce Cloudified Services Sauce On Demand is a cloud-based service that allows you to run automated cross- browser functional tests at high speeds in parallel, so you dont need to maintain testing infrastructure.Easy-to-use tools let you build both manual and automated tests that produce media-rich results, including screen shots and videos of bugs that can be added to any bug tracking system.Sauce Support 65+browser and OS combination . •Operating Systems like Windows, Linux, Mac , •Browsers like Internet Explorer, Chrome, Firefox, Safari, Opera, IPhone, Ipad, Android • All latest browsers versions are available.
Usage of Sauce -Interactive SessionLogin to the Sauce On Demand is a cloud-based service .Select “New Interactive Session” button in Dashboard Page.
Usage of Sauce –Script Mode Unit Test modeSETUPStep 1: Get Python.(Download from python.org)Step 2: Add Python to your PATH.Right click on "My Computer". Select "Properties" from the context menu. In the "System Properties" dialog box, click on the "Advanced" tab. Click on the "Environment Variables" button. Highlight the "Path" Variable in "System variables" section. Click the "Edit" button. Append the following lines to the text inside the "Variable value" text box semi-colon delimited: C:Python25;C:Python25Scripts Click "OK" on the "Edit System Variable" dialog box then "OK" on the "Environment Variables" dialog box to commit the changes.Step 3: Install setuptools Download ez_setup.py Open the cmd console, cd into the directory where the ez_setup.py file was saved and run: python ez_setup.pyStep 4: Get Selenium easy_install -U selenium
Usage of Sauce –Script Mode Codeimport unittestfrom selenium import webdriverclass Selenium2OnSauce(unittest.TestCase): def setUp(self): desired_capabilities = webdriver.DesiredCapabilities.IPHONE desired_capabilities[version] = 5.0 desired_capabilities[platform] = MAC desired_capabilities[name] = Testing Selenium 2 in Python at Sauce’ self.driver = webdriver.Remote( desired_capabilities=desired_capabilities, command_executor="http://USERNAME:API-KEY@ondemand.saucelabs.com:80/wd/hub" ) self.driver.implicitly_wait(30) def test_sauce(self): self.driver.get(http://saucelabs.com/test/guinea-pig) self.assertTrue("I am a page title - Sauce Labs" in self.driver.title); self.driver.find_element_by_id(comments).send_keys(Hello! I am some example comments. I should appear in the page afteryou submit the form) self.driver.find_element_by_id(submit).click() comments = self.driver.find_element_by_id(your_comments) self.assertTrue(Your comments: Hello! I am some example comments. I should appear in the page after you submit the form incomments.text) body = self.driver.find_element_by_xpath(//body) self.assertFalse(I am some other page content in body.text)def tearDown(self): print "Link to your job: https://saucelabs.com/jobs/%s" % self.driver.session_id self.driver.quit()if __name__ == __main__: unittest.main()
Integration of Selenium2 and Sauce ServicesSauce support Selenium2 scripts and can compatible with multipleprogramming languages like Java, Python, NodeJs, Perl.Here, we are using python language for Integration and Functional TestAutomation (Selenium2 with python bindings).Steps to Follow:1. A Python File is written, which will take browsers Name, OS and browser version as run time arguments.2. The Script reads the inputs and invokes the Sauce browser with the given OS and browser combination in Sauce Cloud.3. On invoking the Selenium2 functional script the tests will get executed in the Sauce Cloud.4. Here we used HtmlTestRunner(unit test module for python) for maintaining test sutie.5. The test results can be captured from Sauce or from Html Test Report( which will be generated using HtmlTestRunner).
Integration of Selenium2 and Sauce ServicesJ ConnectivityE Python ScriptN Sauce CloudKI A Job running pythonN script with arguments Test Reports Selenium Test Script
About Sauce ConnectWHAT IS SAUCE CONNECT?Sauce Connect securely proxies browser traffic between Sauce Labscloud-based VMs and your local servers. Connect uses ports 443 and 80for communication with Sauces cloud.WHY SAUCE CONNECT?Sauce Connect helps to do HTML Layout Testing.This can be used by both Front End designers and Testers for performing manual compatibility testing.HOW TO USE SAUCE CONNECT?1.Download Sauce Connect.jar file from the Sauce labs site.2.Run the Jar as below java -jar Sauce-Connect.jar YOUR-SAUCE-USERNAME YOUR- SAUCE-API-KEY3.Login to the Sauce Labs web site using valid user credentials .4.Select “New Interactive Session”5.Browse the url`s (we can use the localhost url`s as well).
Dashboard - Sauce
Features of Sauce Cloud Developer Tools in Every BrowserSelenium RC & WebDriver CompatibleVideo Recordings of Every TestTest Local and Firewalled ServersAny Programming LanguageBrowsers and Mobile Emulators
Advantages & Disadvantages of this Approach Advantages :1. Easy to Integrate with Continuous Integration and Selenium2 test scripts.2. Able to run the Parallel functional tests, which helps to optimize the test execution Time.3. Supports multiple browsers and OS combination including mobile browsers.4. By using this approach, we can perform Functional, Layout, Compatibility testing.5. Sauce, in built support of Video recording and Screenshot capturing is very helpful and good.6. Availability of updated Browsers and Versions.7. Secure Tunnel system. Dis Advantages: 1. Issues with Corporate Proxy environment.