Skip to content

Instantly share code, notes, and snippets.

@rajaraodv
Last active May 21, 2020 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajaraodv/cad799cb118afa92fe3f5268055c557f to your computer and use it in GitHub Desktop.
Save rajaraodv/cad799cb118afa92fe3f5268055c557f to your computer and use it in GitHub Desktop.
# Note: This is just an example in Python. This shows how to print and also how to call that method.
# Feel free to change it to your language and framework needs
import softest
# Get the browser, viewport and device info from a variable like below or from a file or environment variable.
browser = "Firefox"
viewport = "1200X700"
device = "Laptop"
# A Helper to print the test result in the following format:
# Task: <Task Number>, Test Name: <Test Name>, DOM Id:: <id>, Browser: <Browser>, Viewport: <Width x Height>, Device<Device type>, Status: <Pass | Fail>
#
# Example: Task: 1, Test Name: Search field is displayed, DOM Id: DIV__customsear__41, Browser: Chrome, Viewport: 1200 x 700, Device: Laptop, Status: Pass
#
# @param task int - 1, 2 or 3
# @param testName. string - Something meaningful. E.g. 1.1 Search field is displayed
# @param domId string - DOM ID of the element
# @param comparisonResult boolean - The result of comparing the "Expected" value and the "Actual" value.
# @return boolean - returns the same comparison result back so that it can be used for further Assertions in the test code.
def HackathonReport(task, testName, domId,comparisonResult ):
f = open("traditional-V1-TestResults.txt", "a")
report_content = "Task: {task}, Test Name: {test_name}, DOM Id: {dom_id}, Viewport: {viewport}, Device: {device}" \
", Status: {status}\n".format(task=task, test_name=testName, dom_id=domId, viewport=viewport,
device=device, status=comparisonResult)
f.write(report_content)
f.close()
# returns the result so that it can be used for further Assertions in the test code.
return comparisonResult
class Testing(softest.TestCase):
def test_sample(self):
searchField = "DIV__customsear__41"
searchIcon = "DIV__customsear__42"
self.soft_assert(self.assertTrue, HackathonReport(2, "Search field is displayed", searchField, By.id(searchField).isDisplayed()))
self.soft_assert(self.assertTrue, HackathonReport(2, "Search field is displayed", searchField, By.id(searchIcon).isDisplayed()))
self.assert_all()
if __name__ == '__main__':
softest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment