@@ -1042,6 +1042,54 @@ def find_elements_by_image(img_path)
1042
1042
template = Base64 . strict_encode64 File . read img_path
1043
1043
find_elements :image , template
1044
1044
end
1045
+
1046
+ # @since Appium 1.14.0
1047
+ #
1048
+ # Run a set of script against the current session, allowing execution of many commands in one Appium request.
1049
+ # Supports {https://webdriver.io/docs/api.html WebdriverIO} API so far.
1050
+ # Please read {http://appium.io/docs/en/commands/session/execute-driver command API} for more details
1051
+ # about acceptable scripts and the output.
1052
+ #
1053
+ # @param [String] script The string consisting of the script itself
1054
+ # @param [String] type The name of the script type.
1055
+ # Defaults to 'webdriverio'. Depends on server implementation which type is supported.
1056
+ # @param [Integer] timeout_ms The number of `ms` Appium should wait for the script to finish
1057
+ # before killing it due to timeout.
1058
+ #
1059
+ # @return [Appium::Core::Base::Device::ExecuteDriver::Result] The script result parsed by
1060
+ # Appium::Core::Base::Device::ExecuteDriver::Result.
1061
+ #
1062
+ # @raise [::Selenium::WebDriver::Error::UnknownError] If something error happens in the script.
1063
+ # It has the original message.
1064
+ #
1065
+ # @example
1066
+ # script = <<~SCRIPT
1067
+ # const status = await driver.status();
1068
+ # console.warn('warning message');
1069
+ # return [status];
1070
+ # SCRIPT
1071
+ # r = @@driver.execute_driver(script: script, type: 'webdriverio', timeout: 10_000)
1072
+ # r #=> An instance of Appium::Core::Base::Device::ExecuteDriver::Result
1073
+ # r.result #=> The `result` key part as the result of the script
1074
+ # r.logs #=> The `logs` key part as `{'log' => [], 'warn' => [], 'error' => []}`
1075
+ #
1076
+ def execute_driver ( script : '' , type : 'webdriverio' , timeout_ms : nil )
1077
+ @bridge . execute_driver ( script : script , type : type , timeout_ms : timeout_ms )
1078
+ end
1079
+
1080
+ # Convert vanilla element response to ::Selenium::WebDriver::Element
1081
+ #
1082
+ # @param [Hash] id The id which can get as a response from server
1083
+ # @return [::Selenium::WebDriver::Element]
1084
+ #
1085
+ # @example
1086
+ # response = {"element-6066-11e4-a52e-4f735466cecf"=>"xxxx", "ELEMENT"=>"xxxx"}
1087
+ # ele = @driver.convert_to_element(response) #=> ::Selenium::WebDriver::Element
1088
+ # ele.rect #=> Can get the rect of the element
1089
+ #
1090
+ def convert_to_element ( id )
1091
+ @bridge . convert_to_element id
1092
+ end
1045
1093
end # class Driver
1046
1094
end # class Base
1047
1095
end # module Core
0 commit comments