How do I simulate keyboard events in Chromedriver/Selenium for Node.js? - node.js

I'm trying to automate uploading an image file to a server to which I don't have a better form of access (FTP, etc.). I'm using Node.js with Selenium and Chromedriver, and everything is going well until I need to simulate special keys. I've researched a bit, and have found nothing so far. Mac specific answers are ok for this.
I tried this from another answer somewhere, but it's not working for me:
driver.findElement(webdriver.By.name(uploadName))
.click()
.sendKeys(Keys.COMMAND + Keys.SHIFT + 'g')
.sendKeys(imgPath)
.sendKeys(Keys.RETURN);
It fails out because Keys is undefined, but I haven't run across any other ways to get at the commands.

After further research, it seems that this is the wrong way to do this. Selenium and Chromedriver don't really support OS level interaction, but there is an easier way.
driver.findElement(webdriver.By.name(uploadName)).sendKeys(imgPath);
This will target uploadName and then give it the file path passed into sendKeys. This bypasses the messy OS file dialogs.

Related

Use of variable stores and or groups seems to be causing a crash

I tried implementing the variable store function to switch groups in a keyboard layout I developed, only for them to fail to implement in real use. To give you an idea, I'll write the gist of it in pseudocode
begin group(main)
group(main)
store(mode) 'off'
if(mode='off') > use(off)
if(mode='on') > use(on)
group(on) using keys
'+ {key} > set(mode='off')
group(off) using keys
{key} > set(mode='on')
Now When I implemented this on my computer after I reset said computer, I found it wouldn't actually use the different group when I actually installed the keyboard. Stranger yet, when I used the save function to save the variable stores, It cause the keyboard and whatever app I was using it in, to crash.
I did a bit of looking and found that my antivirus program (MCafee livesafe) was quarantining the crashpad_handler.exe files in the keyman installation folders. So after getting them back in my system and repairing the installation, I thought that would solve the problem, but it didn't.
Anybody else experiencing this? What did you do to solve it? For reference, everything was working fine before I reset my PC.

Golem Task respons back with runtime error 2, can't determine the cause

Repo for all code I've been using is updated here . When I run the requestor script it exits with a runtime error 2 (File not found). I am not sure how to further debug this or fix it. So far I've converted my code over to a python slim docker image to better mirror the example. It also works for me when I spin up a docker image that typing and running "/golem/work/imageclassifier.py --trainmodel" works from root. I switched all my code to use absolute paths. I also did make sure the shebang (#!) uses linux end of file characters rather than windows before which was giving me errors. Fixed a bug where my script returns error code 2 when called with no args to now pass.
clf.fit(trainDataGlobal, trainLabelsGlobal)
pkl_file = "classifier.pkl"
with open(pkl_file, 'wb') as file:
pickle.dump(clf, file)
is the only piece I could think of that causes the issue, but as far as I can tell this is the proper way to pickle something in python. Requestor script is also heavily based on the simple service example and I tried to mirror my design to that. I just need help in getting more information while debugging, or guidance on how to move forward from here

Is it possible, to re-convert an .exe to python3-Script again?

I'm writing a program with a Login-Window at the beginning.
Since this program is only for my personal use, there is only
one password set, which is implemented in the code. I built an .exe
via pyinstaller and its not possible to read out information out of the
.exe-file. Now i would like to know, if it's possible to re-convert
the .exe into the python3-script to read out the password, or if there is any other way to get information about the script using the .exe-file.
I have not tried yet, but I found in some blog that the following command works.
python pyinstxtractor.py file_to_decompile

Can you read the length of an mp3 file in python 3 on windows 10?

I am currently creating a music player in python 3.3 and I have a way of opening the mp3/wav files, namely through using through 'os.startfile()', but, this way of running the files means that if I run more than one, the second cancels the first, and the third cancels the second, and so on and so forth, so I only end up running the last file. So, basically, I would like a way of reading the mp3 file length so that I can use 'time.sleep(SongLength)' between the start of each file.
Thanks in advance.
EDIT:
I forgot to mention, but I would prefer to do this using only pre-installed libraries, as i am hoping to publish this online as a part of a (much) larger program
i've managed to do this Using an external module, as after ages of trying to do it without any, i gave up and used tinytag, as it is easy to install and use.
Nothing you can do without external libraries, as far as I know. Try using pymad.
Use it like this:
import mad
SongFile = mad.MadFile("something.mp3")
SongLength = SongFile.total_time()

Watir-webdriver issue with options.yml file

I have been using firewatir for quite some time but thinking of switching to watir-webdriver. I was playing with my existing script and getting an error in the IRB when i use watir-webdriver
Here is my code from existing script
require 'rubygems'
require 'watir-webdriver'
Watir.options_file = 'classes/options.yml'
I am getting a following error
"undefined method `options_file=' for Watir:Module (NoMethodError)"
Can someone point me to the right direction since I am lost on this for couple of days.
Thanks
Watir != Watir-Webdriver. Watir-Webdriver does not support options.yml using options_file, or most likely the options you're setting in it (browser.speed, etc).
You can find a list of available methods, as well as a comparison list of the two here: http://jarib.github.com/watir-webdriver/doc/ .
If you post the options you are setting in that file we can help you determine if they're available in Watir-Webdriver, or how else you use them.
Thanks
You can read more about watir-webdriver at http://watirwebdriver.com/

Resources