unbale to click on button on real device(mobile) - appium

enter image description here#Test
String text= driver.findElement(By.linkText("Log in")).getText();
MobileElement SignuP = (MobileElement) driver.findElement(By.className("android.widget.Button"));
SignuP.click();

By index has work when there is no common id,classpath or accessiblity id
List<WebElement>list =driver.findElements(By.className("android.widget.Button"));
list.get(0).click();
//or we can use xpath
driver.findElement(By.xpath("//android.widget.Button[#text='Log in']")).click();

Related

appium ios - found text element on screen that can start with "a" or "A"

Im running APPIUM Automation for IOS.
I set element to click on it like this :
SerchField = (MobileElement)driver.findElement(By.xpath("//XCUIElementTypeCell[contains(#name,'"+ContactName+"')]"));
ContactName = "abcdef"
But in the mobile screen the contact name show is "Abcdef" so i get an error message that element cannot be found
how can i change the xpath so he will found the element even if the string start with "A" or "a" ?
Thanks !
I assume you're using Java.
Using XPATH logical or
Here #name shoud match any of abcdef, Abcdef.
ContactName = "abcdef";
String contactNameCapitalized = ContactName.substring(0, 1).toUpperCase() + ContactName.substring(1);
String serchFieldxpath = "//XCUIElementTypeCell[(contains(#name,'"+ContactName+"')) or (contains(#name,'"+contactNameCapitalized+"'))]";
SerchField = (MobileElement)driver.findElement(By.xpath(serchFieldxpath));
Using XPATH translate
This translates all upper-case characters to lower-case. ContactName also should be lowercase.
ContactName = "abcdef";
SerchField = (MobileElement)driver.findElement(By.xpath("//XCUIElementTypeCell[contains(translate(#name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'),'"+ContactName+"')]"));

How to setDescription of the name of a element in facet?

I need help about how to add description on facet, here I will put my code so you could see what I am thinking :
List<Facet> facetsExecutor = findFacets("executorFaceting", "caseFileUserApps.activeUsers.executor", fullTextQuery, queryBuilder, includeZeroCounts);
addMoreFacets(najdeniFaceti, facetsExecutor, rb.getString("com..........executor"));
for(int i=0;i<facetsExecutor.size();i++){
String name=facetsExecutor.get(i).getValue();
setDescription(name); //The method setDescription(name) is undefined for the type HibernateIndexSearch
}
Could someone help me, because I need the look when my mouse is over the name of the element in the facet to show a field with specified text(name of the element in the facet)???

Aspose.Words delete line(row) containing a Bookmark

I have a very basic helper method that sets Bookmark's text.
public static Bookmark SetBookmark(this Document doc, string bookmarkName, string value)
{
var bm = doc.Range.Bookmarks[bookmarkName];
if(bm == null)
throw new NullReferenceException(string.Format("Bookmark {0} Not Found!", bookmarkName));
bm.Text = value ?? string.Empty;
return bm;
}
What I need is to remove a bookmark and delete line of text that contains it when a certain condition is met, e.g. when value == null. Any suggestions?
Sample document looks like:
Hello
[Bookmark]
Goodbye
Resulted document after removal:
Hello
Goodbye
Please set the value of Bookmark.Text property to empty string to remove its content and use Bookmark.Remove method to remove the bookmark from the document. Bookmark.Remove method does not remove text inside the bookmark.
I work with Aspose as Developer evangelist.
Please set the value of Bookmark.Text property to empty string to remove its content as shown in following code example. I already shared this in my previous answer.
Document doc = new Document(MyDir + "Bookmark.doc");
// Use the indexer of the Bookmarks collection to obtain the desired bookmark.
Bookmark bookmark = doc.Range.Bookmarks["MyBookmark"];
// Remove the contents of bookmark.
bookmark.Text = "";
doc.Save(MyDir + #"Out.docx");
I work with Aspose as Developer evangelist.

Confusion in assigning form values for input type text

Below are my Page and Spec. I am able to enter the value for firstName but I am getting the below error for lastName. I thought we can assign the value using '=' operator based on Geb doc here http://www.gebish.org/manual/current/navigator.html#text_inputs_and_textareas
geb.error.UnresolvablePropertyException: Unable to resolve lastName as a property to set on NewConsumerApplicationPage's Navigator context
at geb.content.NavigableSupport.propertyMissing(NavigableSupport.groovy:141)
at geb.Browser.propertyMissing(Browser.groovy:182)
at geb.spock.GebSpec.propertyMissing(GebSpec.groovy:59)
at WorkItemSpec.Create workitem(WorkItemSpec.groovy:32)
Page
class NewConsumerApplicationPage extends Page
{static content =
{
newApplicationForm
{ $("form", id: "newApplicationConsumerForm") }
firstName
{newApplicationForm.find("input", id: "newApplication_primaryApplicant:consumerIdentification:firstName")}
lastName
{newApplicationForm.find("input", id: "newApplication_primaryApplicant:consumerIdentification:lastName")}
submitButton
{
$("button", id: "newConsumerApplication_submit")
}
}
}
Spec
def "Create workitem"()
{
given : "I am successfully logged into the application"
to NewConsumerApplicationPage
when:
firstName.value "CCERASTOSTIGMA"
lastName = "PAULA"
submitButton.click()
then :
at ApplicationSummaryPage
}
I've got the answer from Geb mailing list. Posting it here for everyone's benefit.
That's a bit confusing, but this section of the manual is part of the
"form control shortcuts", i.e. it only works on a form content
element. Assuming your form has a name=lastName input element, this
would work:
newApplicationForm.lastName = 'value'
It does not work however when manually selecting input elements of a
form using $/find.

Country name with space not accepted in BlackBerry ObjectChoiceField

I am developing a registration page in BlackBerry app. I am sending all the fields entered to the local server.Country is one of the form fields and is in a ObjectChoiceField. Whenever user selects a country having more than one word for ex: United States of America, it says sign up failed. When user selects country with single name, registration is always successful.Can anybody guide me how can I make the ObjectChoiceField accept the spaces or remove the spaces in the country?
There is no problem in ObjectChoiceField. For example if you want to send the Value like "Black Berry" you must send it to the web service like "Black%20Berry". Because %20 takes the space character. So after you are taking the value form ObjectChoiceField means......
ar[obchfield.getSelectedIndex()];// this is your value say for example:"Black Berry".
Take this below code in seperate Classname Utility.java:
public class Utility {
public static String escapeHTML(String s){
StringBuffer sb = new StringBuffer();
int n = s.length();
for (int i = 0; i < n; i++) {
char c = s.charAt(i);
switch (c) {
case ' ': sb.append("%20"); break;
default: sb.append(c); break;
}
}
return sb.toString();
}}
Then do like this:
Utility.escapeHTML(ar[obchfield.getSelectedIndex()]);//converts the "Black Berry" to "Black%20Berry".
then it returns a String like: "Black%20Berry" and send it to server. Enough.
Your problem is solved.
If you have any doubt come on StackOverFlow chat room name "Life for Blackberry" to clarify Your and our doubts.

Resources