Issue
I am using one generic explicit wait utility which can be used in different places in my test case. Following is the code I have written for the same under Base Test. Here I am looking for a text to present in the screen.For that I have given the parameter "text" in the function VerifyTextPresence.
But after running the script, I am having the below error. How to make it generic so that for any text, I can use this utility. For example, here I am checking for the text "Get" to be present in the screen
Utility Code:
def VerifyTextPresence(self,text):
wait = WebDriverWait(self.driver, 15)
element = wait.until(EC.presence_of_element_located((AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().text(text)'))).text
Test Script:
def test_testcasename(self):
self.VerifyTextPresence("Get")
Error:
io.appium.uiautomator2.common.exceptions.UiSelectorSyntaxException: Could not parse expression `new UiSelector().textGet`: No opening parenthesis after method name at position
Solution
Based on Appium docs
https://appium.io/docs/en/writing-running-appium/android/uiautomator-uiselector/
UiSelector for text should look like:
new UiSelector().text("some text value")
and in your example:
new UiSelector().text(text)
I see 2 issues here:
- no quotes for text
- no reference to python method text arg
also
element = (...).text
will put the text value to element, and looks not helpful.
Try this:
def VerifyTextPresence(self, text):
WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((AppiumBy.ANDROID_UIAUTOMATOR, f"new UiSelector().text(\"{text}\")")))
Answered By - Max Daroshchanka
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.