blob: 9c39ad6751f9faa84f3a9b9d33c5abc584e7db39 [file] [log] [blame]
# Copyright 2017 Google Inc.
#
# 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.
"""Provides constants that are used across different modules.
"""
# Chrome channels to run test cases against.
BETA = 'Beta'
CANARY = 'Canary'
DEV = 'Dev'
STABLE = 'Stable'
# An Xpath pattern that searches through the content-desc for a given string.
CONTAINS_CONTENT_DESC_XPATH_PATTERN = "//*[contains(@content-desc, '%s')]"
# An Xpath pattern that sees if the string is contained a text attribute.
CONTAINS_TEXT_XPATH_PATTERN = "//*[contains(@text, '%s')]"
def GetXpathEqualString(label):
"""Returns the xpath for searching for a text that is Equal to a string.
Args:
label: The xpath label.
Returns:
The xpath for finding the label.
"""
return "//*[@text='%s']" % label
def GetXpathEqualStringIgnoreCase(label):
"""Returns the xpath for searchin a text ignoring case.
Unfortunately Appium does not support XPath 2.0 feature lower-case(@BoundId)
so need to translate W -> w and compare to text.lower()
Args:
label: Text label.
Returns:
The xpath for finding the label.
"""
return ''.join(['//*[translate(@text, \'ABCDEFGHIJKLMNOPQRSTUVWXYZ\',',
' \'abcdefghijklmnopqrstuvwxyz\') = \'%s\']' % label.lower()])