I've been having a lot of trouble with multiline inputs in Selenium. From what I've learned on google, the \n character essentially enters a new line. That makes it such that I can't send a block multiline input as one paragraph text. I want to be able to replace the \n characters with a shift-enter (simultaneous) keystroke.
I've tried using different methods but none of them seem to work.
The string I'm trying to send is:
reply_messages = [
"FREE PILLOW - Thank you for your patience! \n To redeem your FREE pillow, just use the LINK IN OUR BIO and ADD TO CART - just cover shipping, no additional charges!"]
I eventually send the string with the line: reply_input.send_keys(reply_messages)
When I use selenium to input reply_messages, it outputs each of the lines as separate lines.
Essentially, it will send the first line, enter it into the chat window, then send the second line and enter it into the chat window, instead of entering the first line, adding a linebreak, entering the second line, and sending that entire spaced paragraph as one message.
I want to thus replace the linebreak with a shift-enter keystroke so that the browser doesn't register the newline as its own enter keystroke.
With the linebreak, the string is sent as two separate messages.
\n is an escape character which represents a line break. The keyboard keys you press to get that character don't have anything to do with your problem - Enter and Shift+Enter both add a \n to the chat text input box.
What does matter is how the chat window is programmed. When deciding if the button that was pressed means the message should be sent, the chat window isn't looking for text characters, it's looking for keyboard keys.
With Selenium you'll need to simulate the keyboard key presses, not the text that is filled into the text box. Check out this SO answer. As noted in that answer, you'll want to use something like Actions#keyDown or Actions#keyUp.
Related
I have this little challenge.
I want to ask, how do i sort the emails using the color code (light green) as stated in this picture here
I have tried to remove the non emails by scrolling through, but i need a solution that can make it a one click through sorting.
I will appreciate your kind response.
Open the Replace dialog box and enter the following regex in the Find field:
^((.*#[^\.]*)|([^#]+))$\n
Change the radio button to Regular Expressions. This regex pattern finds any line without a dot after # or any line without a #. Note that you need the last line of the document to be empty as shown in line 7 of your document.
Since we are deleting those lines, the "Replace with" field is blank. Now click Replace All.
MS Teams was selected as a communication tool in our company. We do post code into it. And that code contains asterisks, underscores and even numbers! I understand it's business critical feature, but will never, ever, ever need smiley face, smiley face with sunglasses, or part of my code arbitrarily missing stars/underscores and get arbitrarily boldened/empahsized. Even if I write message as code, the asterisks still mingles the text.
Is it somehow possible to turn all these off? Settings or some message header? To send message 'as it was written', without any teenage beautifications?
UPDATE: regarding pressing > to enter verbatim text:
I entered "does not", shift enter, then "really work", go up and created section for text supposed to be verbatim. It really does not work. Then I tried to start immediately with "> " and it equally does not work. On 3rd attempt I noticed some glitching, as I was able to enter bold text, but smiley face did not replace :) To conclude, I'd say "> " unlocks new layer of MS Teams instability and bugs, but cannot be used to enter verbatim text.
If you just need a simple code block, you can send text as code by starting the line with > (enter > then press Space).
Typing in this code block will still replace matching patterns with smilies/emoji, but pasting will not. You should be able to paste your code without issue.
Press Enter twice to escape the code block.
Formatting is retained after sending the message (including leading whitespace which would have been stripped without the code block).
If you need more advanced features, there's a code snippet button hidden in the advanced editor.
After clicking the code snippet button, a modal will open.
You can name the snippet, choose whether or not to wrap text in the snippet, and pick a language to provide highlighting in the snippet. Under these options is a field to paste your code.
Once you finish setting up the snippet, click the Insert button to add the snippet to the current message. You can continue editing the message.
Click the "Send Message" (arrow) button as normal to send the message.
Click the "Expand Preview" link to show the whole code block with the chosen language syntax applied.
I am trying to send utf-8 symbols via serial device to browser and display them. I have found out when I print facepalm emoji 🤦♀️ (on windows 10 Win+.) it has U+200D and ♀ characters behind. Others emojis don't have that. I was using View non-printable unicode characters tool. Also I found, if you print it in notepad it will show you ♀, when you print it in browser address bar ♀ is invisible but if you press backspace you delete it. And finally, if you print it in some html text input, you can delete whole emoji with single backspace. Why is that?
Emoji sequences have more than one code point to signify variations (below may or may not look different for each sequence depending on browser):
🤦 PERSON FACEPALMING U+1F926
🤦♂️ MAN FACEPALMING U+1F926 U+200D U+2642 U+FE0F
🤦♀️ WOMAN FACEPALMING U+1F926 U+200D U+2640 U+FE0F
References:
Emoji List, v13.1 No. 260-262.
Full Emoji List, v13.1, No. 260-262 (With browser-specific images)
Unicode® Standard Annex #29, UNICODE TEXT SEGMENTATION
Some editors/browsers handle the sequences better than others and may not show differences in all variations or may not recognize the latest Unicode specfication and newer emojis.
This is maybe a weird request but hear me out:
I have a huge database at my shop containing product codes, like 87 445 G 6 which I need to check for availability on a supplier's website. The problem is, the supplier's website consists of a web form in which I have to enter the code without spaces, so imagine that I have to manually delete spaces every time I paste a code or write it manually without.
I can't edit the database from which I copy the codes.
I wonder if some sort of plugin, script, or trick can be used directly in browser on the supplier's web form, or some software to modify how the windows clipboard works, maybe some option to copy text without spaces. Using Windows XP.
The OP has probably moved on, but for anyone else looking here, my approach was to tackle this from the windows clipboard side.
For background: I keep a list of my credit card info in Keepass. Sometimes (poorly coded) shopping cart checkout forms don't like spaces in between card numbers. I like storing them with spaces since it's easier to read off that way.
There's various Windows clipboard utilites out there, but it took me a while to find one that could do some processing on the clipboard contents and pasting it out - Clipboard Help and Spell
The program has a way to "save" a bunch of text transformations, and even assign the action to a hotkey.
For reference, my "Find and Replace" action is to find "\s" (without quotes) and leave the Replace textbox empty. "\s" will match whitespace character.
Use the javascript console
You could use the javascript console for your browser to edit the textarea after you paste.
Using Google Chrome (or Firefox)
Paste your text in the text area.
Right click the text area and click Inspect Element
Look at the id for the element
Now switch to the console view
then run these lines (making sure to replace with 'the-id' with your id)
var my_text_area = document.getElementById('the-id'); // Put your id in here
my_text_area.value = my_text_area.value.replace(/ /g,"") // Deletes just spaces
It's even simpler if you have access to jQuery:
$('#the-id').val($('#the-id').val().replace(/ /g, ""))
The replace function is simply using regular expressions to convert spaces to nothing. If you want to replace all whitespace (including newlines) you would use .replace(/\s/g,"").
For firefox, the names are the same but the UI is a little bit different.
Use greasemonkey
You can either write a greasemonkey plugin or try to find one that fits your needs.
I was going thru some content about control characters especially newline character(will focus on this).After going thru
http://en.wikipedia.org/wiki/Control_characters, got to know that \n is the line character in unix
while it is \r\n in windows. Now i got the question how OS comes into picture when iterpreting
ASCII Codes becoz i was under impression when we type any given character on keyboard, any OS send the same
bits and editor interprets that bit and display the corresponding character. Looks like this understanding is
wrong, Because different bit is sent in case of unix(\n) and windows(\r\n) when we press ENTER(new line terminator).As per
new understanding if we press ENTER on diff OS(say unix and windows),different bits are sent to editor and its
responsibilty of text editor to show the typed stuff in new line keeping the underlying OS in picture.Please let me
know if my understanding is correct as this will help me to understand other basics also?
Next question is if above is correct, what can be the reason different OS treat some control characters differently
when they treat all other characters equally? Is it becoz specific bits are already reserved in specific OS?
How an application treats keyboard input varies a bit, actually. When you press return the application is under no obligation to actually generate LF or CR+LF anywhere. E.g. it might decide to just end the current paragraph object and start a new one (e.g. in a word processor). If it's a Windows text editor then it will probably just write CR+LF into the file, while on Unix it just writes an LF.
They keyboard itself is very, very far removed from things you see on the screen or even on the disk. This goes through scan codes, keyboard layouts and other transformations before it ends up as text or markup somewhere.