Selenium - Drexel CCI

Transcription

Selenium Tutorial

What is Selenium? Javascript framework that runs in your webbrowser Works anywhere Javascript is supported Hooks for many other languages Java, Ruby, Python Can simulate a user navigating through pages andthen assert for specific marks on the pages All you need to really know is HTML to startusing it right away

Where to get it? You can use Selenium-Core and customizeeverything But it is easier to just get a Firefox plug-in“Selenium-IDE” that helps you “record” testcases You can record how an app is being used andthen play back those recordings followed byasserts Get everything at: www.openqa.org/selenium/

Selenium IDEThe root of webapplication youwant to testThe log of theevents that wereexecuted, includingany errors orwarning that mayhave occurredThe list ofactions in theactual test caseto execute

Selenium IDEExecutionCommandsRecord testactionsTry the test inthe Web basedTestRunnerReference of thecurrently selectedcommandSpecify commands,including asserts

Test Creation Demo Create test case to log into the gallery Create test case to log out of the gallery

Start PixoryConnect to the ServerGo to the Login ScreenHit the Record Button

Type in Username and PasswordIDE should updateHit recordagain to stopHit submit

Add assertTextPresent andtype the text to search forHit play to make sure yourtest is successful

Creating a Test SuiteA Test Suite inSelenium is just anHTML file thatcontains a table oflinks to tests html head meta content "text/html; charset ISO-8859-1"http-equiv "content-type" title Demo Test Suite /title /head body table id "suiteTable" tbody tr td b Demo Test Suite /b /td /tr tr td a href "./testLogin.html" TestLogin /a /td /tr tr td a href "./testLogout.html" TestLogout /a /td /tr /tbody /table /body /html

Executing the Test Suite Selenium Core is a collection of Javascript andHTML with iFrames Due to security concerns Core must bedeployed within the same server as theapplication being hostedThe simplest way to run Pixory is to just runthe Java application and let it use its ownserverProblems using Core with PixorySelenium IDE is a plug-in for Firefox and thuscan go around these restrictions

Running the Test Suite We basically want to execute the test suiteusing the Selenium IDE plug-in ium/TestRunner.html?baseURL BASE &test file:/// TEST SUITE FILE &auto ner.html?baseURL http://localhost:8081&test file:///Users/ms333/projects/classes/running/v and v/hw3/selenium/test/TestSuite.html&auto true

Test Suite

Test SuiteTest CasesSteps of thetest caseApplicationbeing testedExecutionControl

Test Runner Control

Test Runner ControlPause/PlayExecutionRun Selected TestRun All TestsHighlightElements in theExecutionView the DOMof the currentPage being testedStep throughExecutionControl Speedof ExecutionSummary ofthe TestView the log ofthe currentexecution

TestRunner Demo Execute Tests created inside the FirefoxTestRunner

Selenium IDE The root of web application you want to test The list of actions in the actual test case to execute The log of the events that were execute