I have a string :"Send email to my friend". I want to have this string as a title of a button. But I just want to show only "Send email" and hide the rest of string. is it possible to do that?
You can Add title to button as the text is never changing.
[myButton setTitle:#"Send email" ];
Or if you are getting this text at runtime, you need to do the string manipulation. Class reference for this is available at https://developer.apple.com/library/ios/documentation/uikit/reference/UILabel_Class/Reference/UILabel.html
Just display the first x characters of the string.
[mystr substringToIndex:3];
Related
Actually I'm developing an social-media app where I want that my user can mention more than one user in between of their compliment string just like in Instagram comment section...
on which if someOne tap of their username... it'll lead them to the particular user's profile
desired result example
I'm well aware of the use of buildAnnotationString{} where we can play with textStyle but is there anyway to set onClickListener
you have to create ClickableText not simple Text.
ClickableText(text = AnnotatedString("ClickableText"),
onClick = {
// perform here your action
},
)
I am doing signup page's uitextfields validation programmatically. I have given a single label separately under signup button where it shows the error message.
I have given first name text wrong so that label shows "Please enter valid first name" and I have done the same with Last name and now the message "Please enter valid second name" overlaps the first name error message.
How to get two error messages separately using single label?
you can just change the text of the label while showing the Error message
For Eg:
if (**firstNameTextWrong**)
{
lbl.text=#"Please enter valid first name";
}
else if (**secondNameTextWrong**)
{
lbl.text=#"Please enter valid second name";
}
else
{
//do the right part here
[lbl setHidden:YES];
}
When I pass a single word, e.g. "Gopi", to a text box using sendKeys(), it works. When I try to send multiple words like "Gopi Kingston", the value disappears immediately.
String value = "Gopi Kingston"; // this does not work
Driver.findElement(By.id("searchbox")).sendKeys(value);
String value = "Gopi"; // this works
Driver.findElement(By.id("searchbox")).sendKeys(value);
Here I am Providing u the Text Box Image with its X-path
and Here is the Code for it, that I had tried:
{
String NameTxtBxData = driver.findelement(By.id("ngoName")).gettext();
System.out.println(NameTxtBxData);
}
The element with id "ngoName" is an input. The text from an input is defined in the value property/attribute:
String NameTxtBxData = driver.findElement(By.id("ngoName")).getAttribute("value");
Hi to read a value form a text filed or any input filed there is a hidden attribute value which keeps the value entered by you inside it hence to read the value in the text box simply do it like below
String NameTxtBxData = driver.findelement(By.id("ngoName")).getAttribute("value");
System.out.println(NameTxtBxData);
Hope this helps you
Using below code, it sends key in browser URL not in google search text box.
i want to enter text in google search text field using keyboard event in caps.
driver.get(https://www.google.co.in/);
Actions builder = new Actions(driver);
Action enterText = builder.click(driver.findElement(By.
cssSelector("input[type=text]"))).
keyDown(Keys.SHIFT).
sendKeys("my gmail").
keyUp(Keys.SHIFT).
build();
enterText.perform();
You can use
driver.findelement("YOURELEMENTLOCATOR").sendKeys(Keys.SHIFT,"yourtexttobetyped")
Example,
driver.findElement(By.cssSelector("input[type=text]")).sendKeys(Keys.SHIFT,"stackoverflow")
will send you 'STACKOVERFLOW'. or else you can send the CAPITAL letters directly in the send keys as
driver.findElement(By.cssSelector("input[type=text]")).sendKeys("STACKOVERFLOW")
:)
Below code is to uppercase the first letter of password. It worked perfect for me. Kindly suggest to others too.
String password = "Done123!";
password = password.substring(0, 1).toUpperCase() + password.substring(1);
driver.findElement(By.cssSelector("input[type=text]")).sendKeys(password);
Thanks.
Simple helper function
def capitalized(driver, string):
for char in string:
if char.isUpper():
driver.send_keys(Keys.SHIFT, char)
else:
driver.send_keys(char)