Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add unittest instead of functional test
  • Loading branch information
KazuCocoa committed Apr 11, 2020
commit 07c1ce4624e32d3ceffc3561ecdf1d8135d1824c
4 changes: 2 additions & 2 deletions test/functional/ios/keyboard_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_hide_keyboard_no_key_name(self):

el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
el.click()
el.send_keys('Testing')
el.set_value('Testing')

el = self.driver.find_element_by_class_name('UIAKeyboard')
self.assertTrue(el.is_displayed())
Expand All @@ -68,7 +68,7 @@ def test_is_keyboard_shown(self):

el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
el.click()
el.send_keys('Testing')
el.set_value('Testing')
self.assertTrue(self.driver.is_keyboard_shown())

def _move_to_textbox(self):
Expand Down
61 changes: 61 additions & 0 deletions test/unit/webdriver/webelement_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/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.

import json
import tempfile

import httpretty

from appium.webdriver.webelement import WebElement as MobileWebElement
from test.unit.helper.test_helper import (
android_w3c_driver,
appium_command,
get_httpretty_request_body
)


class TestWebElement(object):

@httpretty.activate
def test_send_key(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/element/element_id/value')
)

element = MobileWebElement(driver, 'element_id', w3c=True)
element.send_keys('happy testing')

d = get_httpretty_request_body(httpretty.last_request())
assert d['text'] == ''.join(d['value'])

@httpretty.activate
def test_send_key_with_file(self):
driver = android_w3c_driver()
# Should not send this file
tmp_f = tempfile.NamedTemporaryFile()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/element/element_id/value')
)

try:
element = MobileWebElement(driver, 'element_id', w3c=True)
element.send_keys(tmp_f.name)
finally:
tmp_f.close()

d = get_httpretty_request_body(httpretty.last_request())
assert d['text'] == ''.join(d['value'])