Sending control key combinations to an element in watir-webdriver - watir

How can you send control key combination to an element when using watir-webdriver?
Currently I am able to send a string to the element with the following code;
$browser.frame(:id,"ws-txt-editor").div(:id,"proxy").send_keys("\b")
or
$browser.frame(:id,"ws-txt-editor").div(:id,"proxy").send_keys(myAttrib[2])
but how do I send arrow keys or things like CTRL-A, CTRL-C or CTRL-V?
I am using watir-webdriver version 0.2.3.

element.send_keys :arrow_down
element.send_keys [:control, "a"], :backspace
etc.

Related

How to make TAG_ALPHA_IDENTIFIER empty not to ask user for a confirmation

My wallet applet requires to perform actions like PLAY TONE etc. But it requires a prompt "Yes or No?" from user. AFAIK, it is TAG_ALPHA_IDENTIFIER which is responsible for that. However, if I try this code below, it still asks user confirmation but now with "#" text. How to get rid of user confirmation at all?
Attempt 1. Failed with NullPtrException
proHdlr.appendTLV(ToolkitConstants.TAG_ALPHA_IDENTIFIER, null, (short)0, (short)0);
proHdlr.send();
Attempt 2. Prompts '##'
proHdlr.appendTLV(ToolkitConstants.TAG_ALPHA_IDENTIFIER, (byte)0, (byte)0);
proHdlr.send();
Attempt 3. Prompts '#'
proHdlr.appendTLV(ToolkitConstants.TAG_ALPHA_IDENTIFIER, (byte)0);
proHdlr.send();
Attempt 4. Prompts Default Text
byte[] ALPHA_MSG = {};
proHdlr.appendTLV(ToolkitConstants.TAG_ALPHA_IDENTIFIER, ALPHA_MSG, (short)0, (short)ALPHA_MSG.length);
proHdlr.send();
According to ETSI 102.223, "8.2 Alpha identifier" section, it should be:
Description
Length
Alpha identifier tag
1
Length(X)
Y
Alpha identifier
X
And there is also "Default text" in documentation, however since "5.3.7 Text attributes" requires Alpha Identifier to be present, Default text should not bother, right?
In this document "6.4.5 PLAY TONE" section, page 45 it says:
if the alpha identifier is provided by the UICC and is a null data object (i.e. length = '00' and no value part), the terminal should not give any information to the user;
That's what I need. How should I do it Java with ProactiveHandler? All my Google searches end up with some text/menu title for Alpha Identifier.
How to get rid of user confirmation and perform the proactive action without it?
a) Try to pass no data at all, i.e. leave out the proHdlr.appendTLV(ToolkitConstants.TAG_ALPHA_IDENTIFIER line.
b) The behavior might be phone-related or more specific modem-related. Check out a MediaTek based one, a Qualcomm based one and an iPhone and compare the results.

How to handle replies in with Pyrogram when using ForceReply?

I am building a telegram bot where I am attempting to get the user to fill in detail about an event and store them in a dictionary which is itself in a list.
However I want it be link a conversation. I want it to look like:
user: /create
bot-reply: What would you like to call it?
user-reply: Chris' birth day
bot-reply: When is it?
user-reply: 08/11/2021
bot-reply: Event Chris birth day on 08/11/2021 has been saved!
To achieve this I plan to use ForceReply which states in the documentation
This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.
The problem is the documentation does not seem to explain how to handle responses.
Currently my code looks like this:
#app.on_message(filters.command('create'))
async def create_countdown(client, message):
global countdowns
countdown = {
'countdown_id': str(uuid4())[:8],
'countdown_owner_id': message.from_user.id,
'countdown_onwner_username': message.from_user.username,
}
try:
await message.reply('What do you want to name the countdown?',
reply_markup=ForceReply()
)
except FloodWait as e:
await asyncio.sleep(e.x)
Looking through the form I have found options like this:
python telegram bot ForceReply callback
which are exactly what I am looking for but they are using different libraries like python-telegram-bot which permit them to use ConversationHandler. It seems to not be part of pyrogram
How to I create user-friendly step-by-step interfaces with pyrogram?
Pyrogram doesn't have a ConversationHandler.
You could use a dict with your users' ID as the key and the state they're in as the value, then you can use that dictionary of states as your reference to know where your User is in the conversation.
Dan: (Pyrogram creator)
A conversation-like feature is not available yet in the lib. One way to do that is saving states into a dictionary using user IDs as keys. Check the dictionary before taking actions so that you know in which step your users are and update it once they successfully go past one action
https://t.me/pyrogramchat/213488

Telethon utils.resolve_invite_link(link) is returning wrong Chat/Channel ID

I'm trying to generate the channel ID of my private channel in Telegram.
I use the following:
link = input("Please provide channel invite link: ")
print(utils.resolve_invite_link(link))
My output looks like the following (I've scrambled the numbers):
(0, 0123456789, 1234567891234567891)
When I view the private channel in the web browser, I get the channel ID as https://web.telegram.org/z/#-9876543210
So the channel ID should be -1009876543210, which I confirmed with IDBot.
Why isn't 9876543210 appearing when I call variable link within utils.resolve_invite_link()? That's the value I expected to see, not 0123456789.
utils.resolve_invite_link(link) no longer works with the new links.
Old links used to pack the channel/group ID inside the links themselves but this is no longer the case. The function will possibly be removed as well in future updates of the library https://github.com/LonamiWebs/Telethon/issues/1723
The most reliable way now is to use CheckChatInviteRequest https://tl.telethon.dev/methods/messages/check_chat_invite.html

Redis-node RPOPLPUSH method

I'm using the great redis-node library and i have a problem right now:
I have an initial list (initStockListKey) created, and the keyname for another list not created yet (inProgressListKey), using rpoplpush command
I try to pop from initStockListKey and push into inProgressListKey, and when verify the list types, i get String type for the one that was created on the fly.
client.rpoplpush(initStockListKey, inProgressListKey, function (err, item)
Can you give me an example of how to do that? As far as know, we can't create an empty list on Redis.

Cucumber "OR" clause?

Is it possible to specify some kind of "OR" (alternative) clause in Cucumber?
I.e. if I have two valid responses to some event I would like my test to pass if either of them happens.
Something like that:
"When I press a button"
"Then I should see the text 'Boo'"
"Or I should see the text 'Foo'"
My particular scenario is a login screen. When I try to log in with some random password, I should see an error message "invalid password" if the server is working or a message "network error" if it is not.
You can't really define OR functionality using the Gherkin but you can pass in a list and check that one of the values in the list matches what was returned.
Define list:
Then the greeting service response will contain one of the following messages
|Hello how are you doing?|
|Welcome to the front door!|
|How has your day been?|
|Come right on in!|
Check list:
#Then("the get messages service response will contain one of the following messages")
public void text_matching_one_of_the_following(List<String> greetingMessages){
boolean success = false;
for(String message : greetingMessages){
assertTrue(textMatchesResponse(message));
}
}
OR is not supported. You can use Given, When, Then, And and But. Please refer to http://docs.behat.org/en/v2.5/guides/1.gherkin.html
But perhaps you could make use of the But keyword to achieve what you are looking for.

Resources