How to use findElementsByIosNsPredicate? - selenium

Appium 1.6
IOS9.3
I used to find iOS element like:
findElementByIosUIAutomation(".tableViews()[0].cells()[1].collectionViews()[0].cells()[0]")
But in XCUITest, how to use findElementsByIosNsPredicate like that? How to write the predicate string ?
Please help me !

Probably, you can try to use something like:
XCUIApplication().tables.element(boundBy: 0).cells.element(boundBy: 1).collectionViews.element(boundBy: 0).cells.element(boundBy: 0)
But I strongly recommend adding accessibilityIdentifier to the UI elements and use it directly:
XCUIApplication().cells["cellAccessibilityIdentifier"]

Related

Geb - how to use hasNot function?

I want to find every navigator that has class "non-clicable" but does not have class "hide".
I write this
$(".non-clicable").hasNot(".hide")
but it's does not work (find every navigator that matches ".non-clicable" and hasNot is like ignored. I also tried to debug and found this:
Already I used
($(".non-clicable") - $(".non-clicable").filter(".hide"))
And it's works correctly but does not look to elegant.
Is there some bug or that I use the function in incorrect way?
You could try:
$(".non-clicable", class: notContains(".hide"))
Or:
$(".non-clicable").not(".hide")
Also work:
$(".non-clicable",not : "hide")

xpath=(//a[contains(text(),'-PPxo-P24-FA')])[2] fails to select

This is what I have
1000000 Venelin-PPxo-P24-FAID-EUR
want to write an XPath for the a based on its contained text. I tried the below but it does not work
xpath=(//a[contains(text(),'-PPxo-P24-FA')])[2]
However, if I try with the below, it works
xpath=(//a[contains(text(),'-PPxo-P24-FAI')])[2]
I am using Selenium IDE 2.9.1 if that makes any contribution to my question.
Hi it seems your Xpath is incorrect
can you try following:
xpath = ("//a[contains(text(),'-PPxo-P24-FA')][2]")
Thank you for all of the answers, guys!
However, I found the solution. It looks like the website contains the text some more times than I need it to. The working code is:
xpath=(//a[contains(text(),'-P24-')])[6]

How to write xpath for the on/off button present in a table for which class is compound class

This element can be turned off or on. As the class is compound class, not sure how to write the xpath. So wrote like this
//tr[1]/td[4]/div[1]/div/div/div[#css='div.ios-switch.on']
Screen shots are attached here
Can you help me in writing the xpath for this element
Use this instead - //tr[1]/td[4]/div[1]/div/div/div[#class='ios-switch on']
"#checkbox1011 [class^='ios-switch']"
or
"#checkbox1011 .ios-switch.on,.ios-switch.off"
Try using these CSS selectors.
//div[#id='checkbox1011']//td[#class='ios-switch-on']
Try:
//tr[1]/td[4]/div[1]/div/div/div[#css='.ios-switch.on' or '.ios-switch.off']
Hopefully this should work.
For the above screenshot, let me assume the username as sabrina galloway.
The toggle switch should present in the same row of username column.
You can use xpath like,
.//tr[./descendant::td[contains(.,'sabrina galloy')]/descendant::*[contains(#class,'ios-switch')]/div[#class='handle']
Use //div[starts-with(#class,'ios-switch')]

Geb: Check if an element is not present/displayed

I want to check that a particular element is not displayed in Geb.
selectedClients { $(".selection") }
Here are several of the stuff I've tried so far: none working.
assertThat(module.selectedClients.not.displayed)
assertThat(module.selectedClients.displayed).isEqualTo(false)
Thanks in advance!
EDIT
To clear the ambiguity, what I was actually checking for here was the presence of child elements within the object. I was able to resolve this, using a size() check.
assertThat(module.selectedClients.size()).isEqualTo("0")
assertThat(!module.selectedClients.displayed)
Try iterating through each element and checking visibility
module.selectedClients.each {
assertThat(it.displayed).isEqualTo(false)
}
I'm not too familiar with junit syntax :/
Simply do this:
if(elementName.size() ==1) or not.

How to replace getColumnModel() function - EXTJS 4

I'm new to EXTJS. I didn't find getColumnModel() in EXTJS4.
Here is my code snippet:
grid.getColumnModel().on('hiddenchange', this.verifyLayout, this, {delay:1});
How can I replace the same in EXTJS 4?
Can anyone help me in this?
Thanks in advance!
Rahul.
In Ext JS 4 Ext.grid.Panel have columnhide and columnshow events which you can use instead of Ext JS 3 Ext.grid.ColumnModel hiddenchange event.
So you can rewrite your code like this:
grid.on('columnhide', this.verifyLayout, this, {delay:1});
grid.on('columnshow', this.verifyLayout, this, {delay:1});
Also if your verifyLayout method process event parameters you will have to modify it.