cbthelper

cbthelper.getCapsBuilder()

Used to get the selenium capability builder

Generating the CapsBuilder pulls in a large amount of data, so user should not call the constrcutor manually

cbthelper.getTestFromId(sessid)

Creates an automated test from the selenium session id

Parameters:sessid – string for the seleneium session/test id. Should come from WebDriver
cbthelper.getTestHistory(options)

Returns a python dictionary with the test history, filtering based on the options given.

Parameters:options – a python dictionary created by the TestHistoryBuilder
cbthelper.getTestHistoryBuilder()

Used to get the TestHistoryBuilder

Can also just call the constructor. Method created to match getCapsBuilder()

cbthelper.login(username, authkey)

Sets the username and authkey used to make the HTTP requests

AutomatedTest

class cbthelper.AutomatedTest.AutomatedTest(testId)

Bases: object

Helpful representation of a selenium test

Parameters:testId – the selenium session ID, usually from webdriver
getSnapshots()

Gets all snapshots for this test

Returns:a list of Snapshot objects for this test
getVideos()

Gets all video recordings for this test

Returns:a list of Video objects for this test
saveAllSnapshots(directory, prefix='image', useDescription=False)

Downloads all snapshots for this test into a directory

Parameters:
  • directory – the directory where the snapshots will be saved
  • prefix – (optional) defines the prefix used for the filenames
  • useDescription – (optional) if true, will use the snapshot description instead of the prefix
saveAllVideos(directory, prefix='video', useDescription=False)

Downloads all videos for this test into a directory

Parameters:
  • directory – the directory where the videos will be saved
  • prefix – (optional) defines the prefix used for the filenames
  • useDescription – (optional) if true, will use the video description instead of the prefix
setDescription(description)

Sets the description for our test in the CBT app

setScore(score)

Sets the score for our test in the CBT app

Parameters:score – should be ‘pass’, ‘fail’, or ‘unset’. The main module exposes SCORE_PASS, SCORE_FAIL, SCORE_UNSET
startRecordingVideo(description='')

Starts recording video for this test

Parameters:description – shortcut for Video.setDescription
Returns:the Video instance we started recording
stop(score='')

Sends the command to our api to stop the selenium test. Similar to driver.quit()

Parameters:score – (optional) shortcut for AutomatedTest.setScore
takeSnapshot(description='')

Sends the command to take a snapshot and returns a Snapshot instance

Parameters:description – (optional) shortcut for Snapshot.setDescription
Returns:the Snapshot instance for this snapshot

CapsBuilder

class cbthelper.CapsBuilder.CapsBuilder

Bases: object

Builder for generating selenium capabilities

All of the with… methods return self for method chaining

build()

Used to generate the capabilites using any options the user specifies

Returns:a python dict object that can be passed to the selenium webdriver
withBrowser(browser)

Sets the browser the user wants to use. The string will be compared against the ‘name’ and ‘api_name’ properties returned from the selenium api.

Parameters:browser – as string specifying the browser (eg. Edge 17, Chrome 55x64)
withBuild(build)

Sets the build name in the web app

withName(name)

Sets the name that will appear in the web app

withPlatform(platform)

Sets the platform (OS) the user wants to use. The string will be compared against the ‘name’ and ‘api_name’ properties returned from the selenium api.

Parameters:platform – a string specifying the platform (eg. Windows 7, Mac 10.13)
withRecordNetwork(bool)

Records network traffice for the length of the test

withRecordVideo(bool)

Records a video for the length of the test

withResolution(width, height)

Sets the screen size for the test

Snapshot

class cbthelper.Snapshot.Snapshot(hash, test)

Bases: object

Represents a snapshot for selenium tests

Parameters:
  • hash – the hash for this image, returned by rest api when taking a screenshot
  • test – an AutomatedTest object that represents a test currently running
getInfo()

Calls out to api to get updated info for this snapshot

Returns:a python dict object with all of the info for this Snapshot
saveLocally(location)

Async method to download this snapshot to the location given

Parameters:location – a string with the location and filename for the image. Should have a .png extension
setDescription(description)

Sets the description for this snapshot

TestHistoryBuilder

class cbthelper.TestHistoryBuilder.TestHistoryBuilder

Bases: object

Builder to generate options for getting test history

All of the with… methods return self for method chaining

build()

Generates the test history options

Returns:a python dict to pass to cbthelper.getTestHistory()
withActive(active)

If set, will only return active or inactive tests

Parameters:active – boolean value
withBrowser(browser)

Will only return tests that used the same browser

Parameters:browser – a string with the browser name and version: (eg. Chrome 65)
withBrowserType(browserType)

Will only return tests that used the same browser type

Parameters:browserType – a string representing the browser family (eg. ‘Chrome’, ‘Edge’, ‘Safari’)
withBuild(build)

Will only return tests that match the build given

withEndDate(endDate)
withLimit(limit)

Sets the max number of tests to return

withName(name)

Will only return tests that match the name given

withPlatform(platform)

Will only return tests with the same platform (OS)

Parameters:platform – string with the platform (eg. ‘Windows 10’, ‘Mac OS 10.13’)
withPlatformType(platformType)

Will only return tests with the same platformType (OS Family)

Parameters:platformType – string with the platform type (eg. ‘Windows’, ‘Mac’, ‘Android’)
withResolution(resolution)

Will only return tests that used the same resolution

Parameters:resolution – a string with the form ‘WIDTHxHEIGHT’ (eg. ‘1024x768’)
withScore(score)

Will only return tests with the score specified (‘pass’, ‘fail’, ‘unset’)

The library contains helpful enums cbthelper.(SCORE_PASS, SCORE_FAIL, SCORE_UNSET)

withStartDate(startDate)
withUrl(url)

Will only return tests that navigate to the same url

Video

class cbthelper.Video.Video(hash, test)

Bases: object

Represents a video recording for a selenium test

Parameters:
  • hash – the hash for this video, returned by rest api when starting a recording
  • test – an AutomatedTest object that represents a test currently running
getInfo()

Calls out to api to get updated info for this video

Returns:a python dict object with all of the info for this video
saveLocally(location)

Async method to download this video to the location given. Recording will be stopped if active.

Parameters:location – a string with the location and filename for the video. Should have a .mp4 extension
setDescription(description)

Sets the description for this video

stopRecording()

Sends the command to stop a video recording