Automatic inputs in Chromium are filled randomly - chromium

Automatic inputs in Chromium are filled randomly
CASE
I want to simulate a barcode scanner without any hardware attached to my computer. From what I learnt, barcode scanners behave as keyboards, so I want to simulate a keyboard HID device.
ENVIRONMENT
Chromium version 53.0.2785.143 Built on Ubuntu , running on LinuxMint 17.2 (64-bit)
ATTEMPTS
1) evdev in python
2) write into dev/input/event* using C++
3) pyautogui
Attempts 1 and 2 behave similarly. Both try to write into dev/input/event* file which corresponds to computer keyboard. But for multiple keypress in loop, the result is not what I expect: if I simulate a keypress repetition, the result goes randomly. Furthermore, some keyboard keys start printing another character which does not correspond to them until the terminal is closed.
So I went with attempt 3 which prints what I want, but the result goes randomly in Chromium.
PROBLEM
pyautogui works in Firefox, but writes randomly inputs in Chromium. It looks like Chromium are avoiding automatic input in its input forms in any website.
Python program:
import pyautogui
pyautogui.typewrite('1234567890123\n', interval=0)
Example
It prints 1234567890123 in Firefox;
It prints 2413123098765 in Chromium. #Random number of 13 digits
QUESTION
Does anybody know why Chromium behaves like that?

Related

Funcunit - why does the speed and reliability of my tests differ depending on whether the test is being run in the active tab in Chrome?

I'm trying out FuncUnit with a simple login/logout script for an app, using Chrome on Windows 7. I've noticed that both the speed and reliability of the test differ depending on if the test is running in the currently selected tab in Chrome.
If the tab isn't selected, the test runs quickly and without error. If the tab is selected, text is typed slowly and sometimes incompletely (so only half the password will be typed before the submit button is clicked), clearly visible elements fail to be found and the test has about a 50% success rate.
Am I missing something here? It's proving less reliable than even QTP unless I deliberately deselect the loaded tab and I'm dubious about any automated test that needs user interaction to pass reliably.
Turned out to be a Chrome version specific issue

Launch GUI program at host through SSH

I've got a Raspberry Pi connected to my TV, with no mouse or keyboard.
I'm sshing into it, starting X and then I want to launch VLC (or any other GUI program, for that matter). If I ssh -X, that will open the program in the computer I'm sshing from, not on the TV.
How can I launch a program and make it appear on the TV?
Slightly less typing than Joachim's (and actually slightly different behavior):
DISPLAY=:0 vlc
This doesn't actually set the DISPLAY variable to :0 for the whole shell session, only passes it to vlc.
So:
If you want to start other X programs in that session after VLC, Joachim's is better.
If you just want to run VLC ASAP, this is faster by 9 keypresses. :)
(I wanted to add this only as a comment, but I didn't have enough points for that, sorry.)
The DISPLAY environment variable needs to have a value set to which display the program should be opened. If you set it to :0, it means the first local screen.
This should in other words open vlc on the first local screen;
export DISPLAY=:0 ; vlc

Selenium clicks on a wrong link (or does not click on a link at all) on certain machines

I am using Selenium WebDriver 2.5.0 (tried 2.13.0, it did not help).
I am trying to click on a link like this:
driver.FindElement(By.PartialLinkText("Customer - Creation").Click();
Before it worked, but I have tried to run the scripts after 3 weeks and
I observe 3 different behaviors on 3 machines:
Machine A: There is no click on the link at all, also there is no error.
Machine B: It clicks a different link! Sometimes one above, sometimes one below.
Machine C (Virtual): It works.
I have not fully tested this (spent half a day today), but did anyone stumble upon such a behaviour?
I have restarted my PC, re-added the Selenium libraries.
"SendKeys(Enter)" helps, but this issue happened not only to links, but to at least radio boxes as well, where "SendKeys(Enter)" does not work.
Please share your thoughts.
Update: Browsers are the same on at least 2 machines, Internet Explorer 8.0
Answered by nebehr.g...#gmail.com at Selenium Issues:
This issue keeps popping up from time to time and is usually returned with request for clarifications. The bottom line is, InternetExplorerDriver calculates coordinates of some objects incorrectly and clicks in the wrong place. One reason for this is zoom value other than 100%; however it is reproducible for some controls for 100% zoom as well.
I suppose it would be helpful if you could create a sample page to demonstrate this issue. In the meantime why don't you use Javascript click() method for offending controls?
http://code.google.com/p/selenium/issues/detail?id=3052
One other thing to check for is the screen resolution (not the desktop resolution but the system level size of text and icons). I have two laptops in my office that are you used for testing, one running Windows 7 and the other running Windows 10. On both, the screen resolution was greater than 100% and Selenium was having problems moving the mouse to the correct location for mouse events like click and hover. As soon as the screen resolution was set to 100%, all mouse actions worked correctly.
Windows 7: http://windows.microsoft.com/en-us/windows7/make-the-text-on-your-screen-larger-or-smaller?v=t
Windows 10: https://superuser.com/questions/951199/windows-10-system-font-size-change
There is a lot of useful info in Andrey's answer and in the Selenium issue he mentions at https://code.google.com/p/selenium/issues/detail?id=3052. Just to tie all those pieces of info together and offer a successful workaround...
I too am experiencing the issue of clicks occurring at the wrong screen coordinates -- four years after the OP first mentioned it! As others have said:
The issue is related to InternetExplorerDriver. I have the problem
when testing IE 9, but not Chrome, Firefox or even IE 8.
As mentioned in the Selenium issue, the website I'm testing uses frames.
I tried several workarounds suggested in this post and elsewhere. All of the following did NOT help:
Updating to the latest InternetExplorerDriver (version 2.47.0)
Maximizing the browser window.
Setting browser zoom to 100%.
Using an action chain, with or without move_by_offset, instead of WebDriver's click() method.
As suggested by Andrey, what DID help is using JavaScript instead of WebDriver's click() method. Here's a line of Python code that does the trick:
driver.execute_script("jQuery('{}').click();".format(css_selector))
This assumes that "driver" is an instance of Selenium WebDriver, and "css_selector" is a string identifying the element you want to click, and that jQuery is loaded.
Sounds like the element isn't present in the page's HTML, but is instead added dynamically once the page is loaded. What happens depends on how fast the machine is and how unique the text is. I'll bet that if you added a long sleep (e.g., a minute) you'd get the same result on all 3 machines. If so, that indicates the single most classic Selenium testing problem - trying to act on pages that aren't complete. You need to find an element to wait on that will guarantee the presence of the link you'd like to click on.
I just had the same issue in FireFox. The zoom was at 100% and the selection was by xpath an certainly correct. Turned out the problem disappeared when I maximized the browerwindow!
code :(python api)
self.driver.maximize_window()

Zebra Label Printer TLP 2824 Plus Prints 2 Labels and Quits

We have the Zebra TLP 2824-Z Plus label printer (ZLP). We recently purchased it, installed the driver and software successfully, and calibrated successfully (held button down at solid green, got single blink then double blink, and then released the button). We went to Zebra and retrieved the updated drivers (certified) and installed them (fyi have tried with and without these drivers - will do nothing without them).
The system it is installed on via USB is a Windows XP Pro 32-bit SP3.
Immediately after configuration, it will do a test print, and let us send the command to feed a label. If we try to print configuration or anything else, to include printing actual labels, it prints two labels/pages, stops, and then blinks red. If we lift the top off and put it down, it blinks green until we press the button. At that time, it will feed about 2 to 3 inches of labels and then print one label. The process repeats indefinitely until we uninstall the printer.
No, clearing the documents will not stop it. A hard reset will not stop it. The only way to get it to do anything else is to uninstall it and start all over again.
How do we fix this issue so we can get a configuration or just print our labels? Or, better yet, what are we doing wrong and how do we do it right? Our last printer worked fine with the exception that they stopped making the labels we used with that printer.
The drive sends down an initialization sequence for the printer based on the settings in the Printer Preferences. If, for example, your Printer preferences say that the printer is Thermal mode instead of direct thermal, the driver will send down the command to set the printer to Thermal mode (Ribbon). If your printer is printing Direct Thermal, and has no ribbon physically installed, the printer will think it is in an error mode with no ribbon. This could cause the issue you are seeing.
Ensure that your Printer Preferences are accurate to your printer's configuration, or disable the initialization sequence in the driver
Yes. Just make sure all the settings are correct.

Why are Selenium IDE playback controls inactive? (How can I run recorded tests?)

I started learning how to use Selenium today. I have never used it before. I downloaded the Selenium IDE (1.0.10) plugin for FireFox (3.5.16). The way it's behaving is not matching up to the docs.
When I click the record button and perform actions in my browser, nothing happens in the IDE (nothing is recorded). (Actually, initially it did record, but now it doesn't) I tried restarting FireFox and that had no effect.
Also, the main controls are now inactive. I've included a screen shot to show what I mean by that. The controls remain inactive even it I click or double click on the name of a test case in the panel on the left.
And one final question -- it appears that a Selenium test case mentions Chrome in its default configuration even though the docs say you can only record tests using FireFox. Should I do anything about that?
If anyone can shed light on any of the above mysteries I would appreciate it. Thanks!
UPDATE
I restarted FireFox again and now it's recording actions, but the controls are still greyed-out as in the screenshot, so I can't play back the test.
The issue is that you are not in the HTML runner mode. The IDE has no concept of ruby or python or c# or Java. That is up to plugins which just essentially do a find an replace.
*chrome means Firefox Chrome. Something that has been around for a lot longer than Google Chrome the browser. It means use the browser chrome which removes a couple sandboxing issues.
If you want to play back the tests you can't go out of the table mode otherwise the IDE won't understand what to do. The code in the screenshot should be stored in a .rb file and that should be executed.
Let me try to unravel mysteries -
As soon as you launch the IDE it would be in recording mode. Do you see last Red button which is enabled.
IDE Tests can be executed only when in the selenese/html format (aka table format). I guess you have changed the format to ruby (I guess so), from Option > Format.
To be able to execute tests change it back to html from option > Format > HTML
Take my words, IDE is only and only for firefox