Multiple keys in sendKeys action - dalekjs

I'm trying to pass multiple keys Cmd Alt P at the same time to Dalek to test page behavior:
test
.open('themes/ribbon/index.html')
.sendKeys('body', '\uE03D\uE00A\u0050') // Cmd Alt P
.assert.attr('body', 'class', 'full')
.done();
And it seems doesn't work as test is failing. I'm using W3C WebDriver spec for key codes reference, but I haven't found clear description on how to send multiple keys (both in Dalek docs and spec), especially with regular, not special ones like Alt and Cmd.
The same test with just a F5 works fine, of course:
test
.open('themes/ribbon/index.html')
.sendKeys('body', '\uE035') // F5
.assert.attr('body', 'class', 'full')
.done();

After some test I came to the conclusion that this is related to a bug in DalekJS, could you please go over to Github and file an issue there?!
Thanks.

Related

system2("bash", "ls") -> cannot execute binary file

Anyone got an idea why
system2("bash", "ls")
would result in (both in R-Gui and RStudio Console)
/usr/bin/ls: /usr/bin/ls: cannot execute binary file
while other shells work w/o issues (see example below) and the "bash" in the RStudio Terminal also works w/o problems. AND if there is a remedy for that?
Working system2 example:
system2("powershell", "dir")
Running R-3.6.3 on Windows 10 here ... with "Git bash" executing as "bash".
PS: just in case someone wonders - I also tried the full path ie /usr/bin/ls -> same result
Ok - this does the trick
system2("bash", input = "ls")
so instead of args = ... as with the powershell command one needs (or more interestingly sometimes 'can') use the input = ... parameter with bash
OR as mentioned in the comments by #oguzismail this will also work
system2("bash", "-c ls")
as well as pointed out by #Christoph
system2("ls")
also works sometimes (ie in some RStudio[?] setups it will not return results in some it will).
But I have come to notice that different combinations of R-versions with different RStudio versions [or more probably Locales] will not always behave consistently of course also depending on the availability of bash commands like ls (more generally /usr/bin) being on the PATH or not.
So choose what suits u best!

After effects (CS6) is 'disabled' when running AfterFX.exe -s argument

Writing my first script with after effects to automate some of my process. I want the script to run at startup of AE with some arguments passed via command line so I use the -s command.
Everything is done except for one problem, when I run AfterFX.exe with the -s, for example if i do this:
"PATH_TO_ADOBE_CS6\Support Files\AfterFX.exe" -s "alert('foo')"
It opens after effects and i do get that 'foo' dialog but for some reason After Effects is 'disabled'. What I mean is I can't do anything, not open any project, nothing. all options are grayed out.
Note that if after effects is already running, and I run the command, it doesnt 'disable' after effects and I get the desired result.
I am using windows and after effects CS6.
note: obviously I intend to do something more complex than alert('foo') which was used a minimalist example to show my issue.
figure it out. for those who find this later, the solution is to add app.exitAfterLaunchAndEval = false.. i.e,
"PATH_TO_ADOBE_CS6\Support Files\AfterFX.exe" -s "app.exitAfterLaunchAndEval = false; alert('foo')"

Watir webdriver - Passing variable to multiple tests?

I have 50+ Watir test scripts which currently just check a specific URL which is defined inside each of them.
Now we are launching 4 more sites and would like to run these tests on all 5 sites. To maintain 5 packs of 50+ tests would be a nightmare in the future.
Is there a way I can pass a variable to all of the individual tests with the URL to visit.
For example
url = "http://site1.com"
That way if we want to then test site 2 we just need to change the url variable and not every single script.
url = "http://site2.com"
Example test:
require "watir-webdriver"
browser = Watir::Browser.new :chrome
browser.goto "http://url.com/"
browser.text_field(:id, "edit-search").set("Accounting")
browser.button(:value,"Search").click
browser.link(:text, "Accounting Manager with a leading US MNC").click
browser.link(:text, "Apply").click
browser.text_field(:id, "edit-firstname").set("hi2")
browser.text_field(:id, "edit-lastname").set("hi")
browser.text_field(:id, "edit-email").set("t#t.com")
browser.text_field(:id, "edit-current-job").set("Test")
browser.radio(:id, "edit-use-stored").click
browser.radio(:id, "edit-existing-cv-319706").click
browser.text_field(:id, "edit-message").set("Testing")
browser.checkbox(:id, "edit-create-alert").click
browser.button(:value,"Apply").click
browser.screenshot.save '..\screenshots\ApplyWithAlertNonRegistered.png'
browser.link(:text, "Home").click
browser.close
While I would recommend moving to an actual test framework, I think the following approaches would work for your situation.
Solution 1 - Pass Value From Batch to Test
In a test script, you can get the parameters passed in from the batch file using the ARGV array.
In your batch file, you could define the URL and then pass to the test script as a parameter.
SET URL="http://site2.com"
ruby test_example1.rb %URL%
ruby test_example2.rb %URL%
Your tests would get the ARGV[0] value and go to it:
browser.goto ARGV[0]
For each test run, you would need to update the batch for the correct url.
Solution 2 - Specify URL in a Helper File
An alternative solution would be to specify the url in a variable that is included by each test. This is probably a better approach, especially if there are multiple variables.
Create a test_helper.rb file with:
url = "http://site1.com"
For each of your test scripts, require this test_helper file and use the url variable:
require "watir-webdriver"
require "test_helper" #(Change path if not in the same folder)
browser = Watir::Browser.new :chrome
browser.goto url
Before each test run, update the test_helper.rb file to point to the correct url.
I like Justin's answer, but another option is Fig Newton. It allows you to change multiple variables depending on the system that you are running on (localhost, on jenkins, UAT, whatever).
Justin - in the test_helper file, would it be possible to set the browser type (chrome, ie, or ff) and pass that variable into each test script; so, if I wanted to change the browser, I would only have to change it in the test_helper file rather than having to go into each test script to change?
If possible, how would this look in the test_helper file and test scripts?
test_helper: type = ff
test script: browser = Watir::Browser.new :type
Thanks!

AutoIt: Send("{DOWN}") not working

I am running an "autoit3.chm" file. When it runs, I would like to send a down key arrow but it doesn't work:
$file = FileGetShortName("C:\Users\PHSD100-SIC\Desktop\AutoIt3.chm")
Run(#ComSpec & " /c start " & $file)
WinWaitActive("AutoIT Help")
Send("{DOWN}")
Well, you're just waiting for the wrong Window Title... Try WinWaitActive("AutoIt Help") and it will work... Your "T" must be a "t"...
To find this out, you just need to check your script output and after your CHM-File has been opened you'll see that your script is still running. But you would have expected it to execute the Send(...) and then terminate. So your script must still be waiting for the expected window to appear. Which will lead you to double check your window title, probably you'll directly copy the window title with the AutoIt Window Info Tool, and this shows your mistake. Correct it. Viola, be happy =)
Besides: You don't need to run a Command-Prompt first, you can call ShellExecute($file) directly instead.
If you use the AutoIt Window Info tool, it helps with these issues, and it's also good practice to debug with ConsoleWrite(...)s.
For example, a simple one would be as before. However, you should probably use timeouts or variables and use the return for success/fail.
WinWaitActive("Window")
ConsoleWrite("Success")
Send("{DOWN}")
ConsoleWrite("Success")
Use following syntax for down key enter
Send("{DOWN 2}")
and similar for Up key enter
Send("{UP 2}")

Silencing ChromeDriver.exe logging

I am running ruby unit tests against Chrome using watir-webdriver. Whenever a test is run and chromedriver.exe is launched output similar to below appears:
Started ChromeDriver
port=9515
version=26.0.1383.0
log=C:\Home\Server\Test\Watir\web\chromedriver.log
[5468:8796:0404/150755:ERROR:accelerated_surface_win.cc(208)] Reseting D3D device
[5468:8996:0404/150758:ERROR:textfield.h(156)] NOT IMPLEMENTED
[WARNING:..\..\..\..\flash\platform\pepper\pep_module.cpp(63)] SANDBOXED
None of this impacts the correct functioning of the tests, but as one might imagine the appearance of "ERROR" and "WARNING" might be rather confusing to, for example, parsing rules in Jenkins looking for failures. Sure I can get really fancy with regular expression in the parsing rules, but it would be really nice to turn off this verbose and unnecessary logging on the part of chromedriver.exe. I have seen many mentions of this searching for an answer. No one has come up with a solution. Yes, chromedriver possibly has a "--silent" option, but there seems to be no way to pass that to the executable. Code similar to below is supposed to work, but has zero effect as far as I can see. Any ideas?
profile = Selenium::WebDriver::Chrome::Profile.new
profile['--cant-make-any-switches-work-here-how-about-you'] = true
browser = Watir::Browser.new :chrome, :profile => profile, :switches => %w[--ignore-certificate-errors --disable-extensions --disable-popup-blocking --disable-translate--allow-file-access]
Here's help for anyone else searching
Find ...selenium\webdriver\chrome\service.rb
Path start may differ on your system
And I added "-silent" to the passed parameters .... However, this silenced everything but the error/warning messages.
def initialize(executable_path, port)
#uri = URI.parse "http://#{Platform.localhost}:#{port}"
server_command = [executable_path, " -silent", "--port=#{port}"]
#process = ChildProcess.build(*server_command)
#socket_poller = SocketPoller.new Platform.localhost, port, START_TIMEOUT
#process.io.inherit! if $DEBUG == true
end
set chromeOptions with key --log-level=3 this should shut it up
I was able to divert the hundreds, yes hundreds, of chrome driver log messages that were showing up in cucumber stdout by using the :service_log_path argument.
#browser = Watir::Browser.new :chrome, :service_log_path => 'chromedriver.out'
the '-silent', or '--silent', or ' -silent', or ' --silent' parameter suggested above did nothing when I added it to ...selenium\webdriver\chrome\service.rb. And having to tweak the gem itself is not a particularly viable solution.
I couldn't find a place to capture the chromedriver stderr and divert it to null (not to mention having to handle doing that in windows and in *nix/osx)
The driver should default to something way less verbose. In this case INFO is way too verbose as hundreds of log entries pop out as INFO, 90%+ of them identical.
At least the :service_log_path argument works most of them.
You can try -Dwebdriver.chrome.logfile="/dev/null" and/or -Dwebdriver.chrome.args="--disable-logging" to the options of java that runs selenium-server-standalone-what.ever.jar

Resources