Hello, yesterday I update to the latest appium-python client and immediately got test failures when running:
self.driver.execute_script(“mobile: scroll”, {“direction”: “down”, “text”: user})
The error is below. Any help is appreciated.
def execute_script(self, script, *args):
Synchronously Executes JavaScript in the current window/frame.
:Args:
- script: The JavaScript to execute.
- \*args: Any applicable arguments for your JavaScript.
:Usage:
driver.execute_script('return document.title;')
converted_args = list(args)
command = None
if self.w3c:
E AttributeError: ‘WebDriver’ object has no attribute ‘w3c’
I also tried the following code using the w3c actions suggested on the python-client git, but I still got the same error. This time is when getting window_size()
Code:
def scroll_down(self):
window = self.__appium_driver.get_window_size()
actions = ActionBuilder(self.__appium_driver)
actions.pointer_action.move_to_location(window.width / 2, window.height * 8 / 10)
actions.pointer_action.pointer_down()
actions.pointer_action.move_to_location(window.width / 2, window.height / 10)
actions.pointer_action.release()
actions.perform()
Error:
def get_window_size(self, windowHandle=‘current’):
Gets the width and height of the current window.
:Usage:
driver.get_window_size()
command = Command.GET_WINDOW_SIZE
if self.w3c:
E AttributeError: ‘WebDriver’ object has no attribute ‘w3c’
Deprecated
MultiAction and TouchAction are deprecated. Please use W3C WebDriver actions.
appium/webdriver/extensions/action_helpers.py
/documentation/webdriver/actions_api/mouse/
https://www.youtube.com/watch?v=oAJ7jwMNFVU
Appium Pro: iOS-Specific Touch Action Methods
Appium Pro: Automating Complex Gestures with the W3C Actions API
launch_app, close_app and reset are deprecated. Please read issues#15807 for more details
Does that help?
Thank you wreed. I did read that and one of the links there shows that execute_script should still work(?)
https://appiumpro.com/editions/30-ios-specific-touch-action-methods
My last post also shows the actionbuilder method snippet for scrolling, but I’m still using get_window_size() and that gives me the error.
I would like to find a way to do this without having to back to v1.
Yeah, this is confusing to me too. I’m not a Python guy. I’m looking at the client repo tests:
github.com
#!/usr/bin/env python
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING, Any, Dict
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
if TYPE_CHECKING:
from appium.webdriver.webdriver import WebDriver
This file has been truncated. show original
Seems like they are using ‘self.execute_script’ instead of ‘self.driver.execute_script’. I probably don’t understand the difference though.
I also wonder if in your first script you might try: if self.driver.w3c
. But I’m not sure about this.
Thank you both. I am going to crosspost this to the python-client git and see if it is a bug on their end