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)
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 working on a Blazor textarea input. What I want to achieve is whenever user types "#" character, I am going to popup a small window and they can select something from it. Whatever they select, I will insert that text into the textarea, right after where they typed the "#".
I got this HTML:
<textarea rows="10" class="form-control" id="CSTemplate" #bind="original" #oninput="(e => InputHandler(e.Value))" #onkeypress="#(e => KeyWasPressed(e))"></textarea>
And the codes are:
protected void InputHandler(object value)
{
original = value.ToString();
}
private void KeyWasPressed(KeyboardEventArgs args)
{
if (args.Key == "#")
{
showVariables = true;
}
}
protected void AddVariable(string v)
{
original += v + " ";
showVariables = false;
}
This worked very well. The showVariables boolean is how I control the pop-up window and AddVariable function is how I add the selected text back to the textarea.
However, there is one small problem. If I've already typed certain text and then I go back to any previous position and typed "#", menu will still pop-up no problem, but when user selects the text and the insert is of course only appended to the end of the text. I am having trouble trying to get the exact caret position of when the "#" was so I only append the text right after the "#", not to the end of the input.
Thanks a lot!
I did fast demo app, check it https://github.com/Lupusa87/BlazorDisplayMenuAtCaret
I got it - I was able to use JSInterop to obtain the cursor position $('#CSTemplate').prop("selectionStart") and save the value in a variable. Then use this value later in the AddVariable function.
you can set your condition in InputHandler and when you are checking for the # to see if it's inputed you can also get the length to see that if it's just an # or it has some characters before or after it obviously when the length is 1 and value is # it means there is just an # and if length is more than one then ...
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);
I create a markup keyboard for my telegram bot, anybody know how I can add emotion in the options look like the below link ?
Thanks
salam seyed. the problem is not limit to keyboard. in the message also you have same problem for sending emoji. you must pack the emoji unicode bytes before send:
$message .= iconv('UCS-4LE', 'UTF-8', pack('V', 0x1F453));
and in this link you can see the list of emoji code that you need enter in the above code.
Steps to perform:
copy the emotion from your telegram client;
paste it into your IDE as String variable;
Use the variable as Inline button's label
Here is a java example:
public InlineKeyboardMarkup getBtn() {
String label = "\uD83D\uDE04Laughing button";
String label2 = "\uD83D\uDE21Angry button";
InlineKeyboardMarkup markup = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> keyboard = new ArrayList<>();
List<InlineKeyboardButton> row_1 = new ArrayList<>();
List<InlineKeyboardButton> row_2 = new ArrayList<>();
row_1.add(new InlineKeyboardButton(label).setCallbackData("1"));
row_2.add(new InlineKeyboardButton(label2).setCallbackData("2"));
keyboard.add(row_1);
keyboard.add(row_2);
markup.setKeyboard(keyboard);
return markup;
}
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];