Class: Maze::Api::Appium::FileManager

Inherits:
Object
  • Object
show all
Defined in:
lib/maze/api/appium/file_manager.rb

Overview

Provides operations for working with files during Appium runs.

Instance Method Summary collapse

Constructor Details

#initializeFileManager

param driver



7
8
9
# File 'lib/maze/api/appium/file_manager.rb', line 7

def initialize
  @driver = Maze.driver
end

Instance Method Details

#write_app_file(contents, filename) ⇒ Object

Creates a file with the given contents on the device (using Appium). The file will be located in the app’s Documents directory for iOS and /sdcard/Android/data/<app-id>/ for Android.

Parameters:

  • contents (String)

    Content of the file to be written

  • filename (String)

    Name (with no path) of the file to be written on the device



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/maze/api/appium/file_manager.rb', line 15

def write_app_file(contents, filename)
  path = case Maze::Helper.get_current_platform
         when 'ios'
           "@#{@driver.app_id}/Documents/#{filename}"
         when 'android'
           "/sdcard/Android/data/#{@driver.app_id}/files/#{filename}"
         end

  $logger.debug "Pushing file to '#{path}' with contents: #{contents}"
  @driver.push_file(path, contents)
end