Skip to content

Commit

Permalink
Add screenshot tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdav committed Jul 19, 2023
1 parent ca00857 commit a8bfac4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Tests/UnitTests/APIToRequestMappingTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import XCTest
@testable import WebDriver

let base64image: String = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAHCAYAAAA1WQxeAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAB2GAAAdhgFdohOBAAAABmJLR0QA/wD/AP+gvaeTAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIzLTA3LTEzVDIwOjAxOjQ1KzAwOjAwCWqxhgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMy0wNy0xM1QyMDowMTo0NSswMDowMHg3CToAAAC2SURBVBhXY/iPDG7c+///5y8oBwJQFRj4/P9f3QNhn78Appi+fP3LkNfxnIFh43oGBiE+BoYjZxkYHj5iYFi2goHhzVsGpoePfjBMrrzLUNT4jIEh2IaBQZCTgaF1EgODkiIDg4gwA9iKpILL/xnkL/xnkLzyv8UUaIVL2P//Xz5DrGAAgoPzVjDosRxmaG4UZxArjAAa/YGBYfdxkBTEhP37bv9/+eIDWAcYHDsHNOEbkPH/PwCcrZANcnx9SAAAAABJRU5ErkJggg=="

/// Tests how usage of high-level Session/Element APIs map to lower-level requests
class APIToRequestMappingTests : XCTestCase {
func testSessionAndElement() throws {
Expand All @@ -12,6 +14,9 @@ class APIToRequestMappingTests : XCTestCase {
mockWebDriver.expect(path: "session/mySession/title", method: .get) { WebDriverResponse(value: "mySession.title") }
XCTAssertEqual(session.title, "mySession.title")

mockWebDriver.expect(path: "session/mySession/screenshot", method: .get) { WebDriverResponse(value: base64image) }
XCTAssertEqual(session.screenshot(), base64image)

mockWebDriver.expect(path: "session/mySession/element", method: .post, type: Session.ElementRequest.self) {
XCTAssertEqual($0.using, "name")
XCTAssertEqual($0.value, "myElement.name")
Expand Down
5 changes: 5 additions & 0 deletions Tests/WebDriverTests/SessionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class SessionTests : XCTestCase {
XCTAssertEqual(title, "System Information")
}

public func testScreenshot() {
let image: String = Self.session.screenshot()
XCTAssert(!image.isEmpty)
}

public func testMaximizeAndRestore() {
guard let element = Self.session.findElement(byName: "Maximize") else {
XCTAssert(false, "Maximize button not found")
Expand Down

0 comments on commit a8bfac4

Please sign in to comment.