WebDriverAPI (python)

这篇博客详细介绍了如何使用Python的WebDriverAPI进行各种操作,包括内部函数、关闭应用、查找元素、获取日志、截图和获取UI树信息等。内容涵盖了从基本的页面导航到复杂的元素交互,如拖放、滚动、点击等,还涉及到IME引擎的激活和关闭,以及日志获取和截图功能,是Python自动化测试的重要参考资料。

内部函数

'_addCommands',
'_file_detector',
'_is_remote',
'_mobile',
'_switch_to',
'_unwrap_value',
'_web_element_cls',
'_wrap_value',


'activate_ime_engine',
'active_ime_engine',
'add_cookie',
'app_strings',
'application_cache',
'available_ime_engines',
'back',
'background_app',
'capabilities',
'close',

关闭应用

close_app


'command_executor',
'context',
'contexts',
'create_web_element',
'current_activity',
'current_context',
'current_url',
'current_window_handle',
'deactivate_ime_engine',
'delete_all_cookies',
'delete_cookie',
'desired_capabilities',
'device_time',
'drag_and_drop',
'end_test_coverage',
'error_handler',
'execute',
'execute_async_script',
'execute_script',
'file_detector',
'file_detector_context',

查找元素

'find_element',
'find_element_by_accessibility_id',
'find_element_by_android_uiautomator',
'find_element_by_class_name',
'find_element_by_css_selector',
'find_element_by_id',
'find_element_by_ios_predicate',
'find_element_by_ios_uiautomation',
'find_element_by_link_text',
'find_element_by_name',
'find_element_by_partial_link_text',
'find_element_by_tag_name',
'find_element_by_xpath',
'find_elements',
'find_elements_by_accessibility_id',
'find_elements_by_android_uiautomator',
'find_elements_by_class_name',
'find_elements_by_css_selector',
'find_elements_by_id',
'find_elements_by_ios_predicate',
'find_elements_by_ios_uiautomation',
'find_elements_by_link_text',
'find_elements_by_name',
'find_elements_by_partial_link_text',
'find_elements_by_tag_name',
'find_elements_by_xpath',


'flick',
'forward',
'get',
'get_cookie',
'get_cookies',

获取日志

get_log

get_log(log_type) method of appium.webdriver.webdriver.WebDriver instance
    Gets the log for a given log type

    :Args:
     - log_type: type of log that which will be returned

    :Usage:
        driver.get_log('browser')
        driver.get_log('driver')
        driver.get_log('client')
        driver.get_log('server')
Supported types : {
"syslog" : "System Logs - Device logs for iOS applications on real devices and simulators" ,
"crashlog" : "Crash Logs - Crash reports for iOS applications on real devices and simulators" ,
"performance" : "Performance Logs - Debug Timelines on real devices and simulators" }

 

截图

get_screenshot_as_base64

Gets the screenshot of the current window as a base64 encoded string
       which is useful in embedded images in HTML.

    :Usage:
        driver.get_screenshot_as_base64()

get_screenshot_as_file

get_screenshot_as_file(filename) method of appium.webdriver.webdriver.WebDriver instance
    Gets the screenshot of the current window. Returns False if there is
       any IOError, else returns True. Use full paths in your filename.

    :Args:
     - filename: The full path you wish to save your screenshot to.

    :Usage:
        driver.get_screenshot_as_file('/Screenshots/foo.png')

get_screenshot_as_png

get_screenshot_as_png() method of appium.webdriver.webdriver.WebDriver instance
    Gets the screenshot of the current window as a binary data.

    :Usage:
        driver.get_screenshot_as_png()

 

 

'get_settings',
'get_window_position',
'get_window_size',
'hide_keyboard',
'implicitly_wait',
'install_app',
'is_app_installed',
'is_ime_active',
'keyevent',
'launch_app',
'lock',
'log_types',
'long_press_keycode',
'maximize_window',
'mobile',
'name',
'network_connection',
'open_notifications',
'orientation',

获取UI树信息

page_source

 

'pinch',
'press_keycode',
'pull_file',
'pull_folder',
'push_file',
'quit',
'refresh',
'remove_app',
'reset',
'save_screenshot',
'scroll',
'session_id',
'set_location',
'set_network_connection',
'set_page_load_timeout',
'set_script_timeout',
'set_value',
'set_window_position',
'set_window_size',
'shake',
'start_activity',
'start_client',
'start_session',
'stop_client',
'swipe',
'switch_to',
'switch_to_active_element',
'switch_to_alert',
'switch_to_default_content',
'switch_to_frame',
'switch_to_window',
'tap',
'title',
'toggle_location_services',
'touch_id',
'update_settings',
'w3c',
'wait_activity',
'window_handles',
'zoom'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值