I am doing QA and recently started using appium and cucumber to automate some tests and am still new to this.
I succeeded in what I wanted to automate using some functions like this one.
def function(element_name)
find_element(:xpath,
'//XCUIElementTypeOther[#name="' + element_name + '"]'
).click
end
This works for what I want, but now I am trying to redo the same functions but using contains. Something like this
def function(element_name)
find_element(:xpath,
'//*[contains(text(), element_name)]'
).click
end
What I'm getting is
An element could not be located on the page using the given search parameters.
I think I am just not using contains the right way but I am really not sure.
Xpath is not a good way for searching elements in Appium/XCUITest as it is often too slow and might not work as you expect it to work (your case with contains).
Instead you should you try XCUITest native locator strategies: iOSNsPredicate or iOSClassChain, e.g.
driver.find_element_by_ios_predicate("label contains 'Some text'")
You can check more examples here: python client tests, java client tests
the way you are using contains is correct, the only problem is its not finding the element.
If XPATH is not working , why dont you try with relative path e.g. below
def function(element_name)
//tbody//td[contains(text(),element_name)]
Related
https://phytozome-next.jgi.doe.gov/blast-search
on this website if i use the blast tool with the sequence "MARPFTLSLLSLCLLLSAWSCFGGSSSTNRFNICQLNSLNALKPDHRVETDGGLVETWSSRHPELECAGVTVTRRTLYRNGFQMPSYSPYSQMIMAIQGKGALGLALSGCAETYEEPAKESSSSSQKPSDSHQKIRQFDQGHVMLIPRGVPFWIFNTGDEPLITVTLLDTSSEDNQLDQSPREFYLAGNPDIEHPEAMKEKQQQQAEEEGGNVLSGFGKRFLARALNIDQDTANKLISPDDEMKQIVKLKEGLSVISPKWQGQQEDEDEDDDDEDEDESVSRPSRRPSHGKRVHKEEETVVEPYPHGKHVHKEVEKEVEPLPPRKHVHKEEEKEIEPLPPRRSRHHHDEGEDEGEEEEKPRARRTRGPTPSPKGEGHRGVEEEDESEDTKGHKTRHEKTRHEKSWKEHRPEGEDVEKGEAHEEWETRPSKDKPHGSNGLDETICSSKLQFNIARPKGADFYNPKAGRIKNLNSQSLPALQHFGLSAQYVVLYKNGIYSPHWNMDANSVIYVIRGQGQVRVVNNEGIVMFDDELKKGQLLVVPQNFMVAEEAGDQGFEYVVFKTNDNAVTSYLKETFRAFPAEVLVNIYKLKHSQVHDLKYNGNLGPLVNPENSLDQSS"
along with Archaeplastida selected in order to return all results i get 100 results
when i use selenium with the chrome driver the web page informs me that "The Phytozome service couldn't get what you were after."
i have narrowed the problem down to something involving send keys, since if i run selenium all the way up to the point where it sends keys and i input the keys myself it works just fine.
When you say you "input the keys yourself", are you really typing those hundreds of random-looking letters yourself, one at a time? That looks about impossible.
It totally depends on the particular website's programming, but it could be a timing issue. You can try a separate SendKeys() call for each character with a pause between each one.
i am not sure what the problem was but i simply used execute script instead of send keys. that posed another issue, which i resolved by sending a space key and then clicking backspace.
i tried everything including sending the keys one by one with a space in between and this was the only thing that worked.
I've been given an educational assignment during which I write Gherkin scenarios to test a website using Python 3.6, Splinter and Behave. I'm making some pretty good progress but I'm stuck on this little thing. Currently I've succeeded in getting a file to download through a headless instance of Chrome in Ubuntu. However, for the last step of the scenario to pass, I need to verify the file's existence. After a lot of searching I've found a method that works, which is:
assert os.path.isfile('/home/[USERNAME]/Downloads/file.csv')
However, in order to make this test more compatible with other computers, I'd like the path to the file to be shorter and simpler. Most importantly, not using this system's username.
I'm new to all of this so this could very well be a dumb question, but I've been searching all over the place and I simply can't find an answer.
You could rewrite the path using the ~ which replaces /home/[USERNAME]/, so it would become ~/Downloads/file.csv. Then, you could use Python's os.path.expanduser() function as follows:
assert os.path.isfile(os.path.expanduser('~/Downloads/file.csv'))
os.path.expanderuser() will automatically expand it to /home/[USERNAME]/ for you.
If you need to get Downloads folder path, than you can use answer to this question: python - Finding the user's "Downloads" folder
Bear with me, I am very new to this. I am writing in Python using Selenium Webdriver.
I have a test written out and I want to make an assertion to find is a class is present. I have tried multiple ways to go about to do this however i feel as though it is not working correctly.
I have attached a photo of the code I am looking at (the highlighted line) and this is what I have so far. This fires which is a pop up to notify a success the form was submitted.
self.assertTrue(driver.find_element(By.XPATH, '//*[#id="message-center"]/div'))
I would take advantage of the .find_elements method. It will return an empty list if no such elements are found.
self.assertTrue(driver.find_elements(By.XPATH, '//*[#id="message-center"]/div').count() > 0);
So i am getting the path id('page-content')/x:div[6]/x:div/x:div/x:div/x:a[1]/x:img
How would i go about clicking the img?
I've tried
lol=find_element_by_xpath("//div[#class='emoji-items nano-content']//a[#title=':heart:']/img")
as well as
lol=find_element_by_xpath("//a[#title=':heart:']/img")
which i believe should work, but it instead gives me an error
What i did is: select all links elements (a) that contains heart in the title.
I tried to avoid using #title= because sometimes you might have issues due syntax used in the methods for finding the element or in other methods due to special characters like :.
The resulted path was:
//a[contains(#title, 'heart')]
If more elements are found you need to add another element in front of this to restrict the section that is searched in.
I am trying to take advantage of JAXB code generation from a XML Schema to use in an Android project through SimpleXML library, which uses another type of Assertion than JAXB (I do not want to include a 9MB lib tu support JAXB in my Android project). See question previously asked
Basically, I am writing a small Python script to perform the required changes on each Java file generated through the xcj tool, and so far it is working for import deletion/modification, simple line annotation, and also the annotation for which a List #XMLElement needs to be converted to an #ElementList one.
The only issue I am facing right now is for removing annotations on several lines, such as #XMLSeeAlso or #XMLType like the following
#XmlType(name = "AnimatedPictureType", propOrder = {
"resources",
"animation",
"caption"
})
or
#XmlSeeAlso({
BackgroundRGBColorType.class,
ForegroundRGBColorType.class
})
I tried different strategies using either Multineline, DotAll, or both, but without any success. I am new to "advanced" regex usage as well as Python so I am probably missing something silly.
For my simple XSD processing that is the only step I cannot get running to achieve a fully automated script using xcj and then automatically convert JAXB annotations into Simple XML ones.
Thank you in advance for your help.
#Xml.*\}\) with dotall enabled should as far as i know match any annotation starting with #Xml and ending with "})", even when it is multiline.
For a good view of what your regex actually matches you could always test your regular expressions at websites like https://pythex.org/