Ruby / Capybara - How to use a JQuery command in Capybara - ruby

I have the following JQuery script that are working in my Chrome console. However, it is not working when I use it in my Capybara test. What am I doing wrong?
Script that works in my console
$('#skuTabNavigation a[href="#tabImages"]').trigger('click');
Script in my Capybara test. Did not work
script = '$("#skuTabNavigation a[href="#tabImages"]").trigger("click")';
page.execute_script(script)
Terminal MAC error
Failure/Error: page.execute_script(script)
Selenium::WebDriver::Error::UnknownError:
unknown error: Runtime.evaluate threw exception: SyntaxError: missing ) after argument list
(Session info: headless chrome=73.0.3683.75)
(Driver info: chromedriver=2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e),platform=Mac OS X 10.12.6 x86_64)

It looks like you need to escape your quotes; you've got 2 sets of double quotes nested inside your capybara script example.
You might try escaping the quotes around tabImages:
script = "$('#skuTabNavigation a[href=\"#tabImages\"]').trigger('click')";

Related

How do I resolve regex parsing error while opening RStudio on Mac

I see this error when I try opening RStudio on Mac after installing it:
Unexpected exception: Escape sequence was neither a valid property nor a valid character class name. The error occurred while parsing the regular expression fragment: 'LUDE=C:\py>>>HERE>>>thon27\inc'.
From the log:
ERROR R SUICIDE: Unexpected exception: Escape sequence was neither a valid property nor a valid character class name. The error occurred while parsing the regular expression fragment: 'LUDE=C:\py>>>HERE>>>thon27\inc'.; LOGGED FROM: void <anonymous namespace>::rSuicide(const std::string &) /Users/rstudio/rstudio/src/cpp/session/SessionMain.cpp:1023
How do I resolve the issue?
The RStudio installer version is 1.1.463. I saw the same issue with 1.1.453 as well. I am in Mac OS Sierra (version 10.12.6).
I had some erroneous paths in $ cat /etc/paths. Removed them and RStudio works fine.

Phantomjs headless on linux: WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP

I am experiencing issue with Phantomjs headless automation testing on linux. We are using Jenkins as our CI server. However, we are getting the error below:
phantomjs://platform/console++.js:263 in error
[ERROR - 2016-12-09T19:45:12.372Z] WebElementLocator -
_handleLocateCommand - Element(s) NOT Found: GAVE UP.
Search Stop Time: 1481312712354
phantomjs://platform/console++.js:263 in error
How we start phantomjs:
phantomjs --webdriver=8001
Environment:
Phantomjs: 2.1.1
Jenkins: 1.598
Linux: Linux xxx1247 2.6.32-573.12.1.el6.x86_64
Ruby: 1.9.3
Cucumber: 2.1.4
Selenium-webdriver: 2.53
Please share your solution. Thanks!
There can be a few causes for this. One of them can be that the get action to the Web URL failed. That means you are operating on an empty result, which will throw that error.
Since the webpage is not fetched, the element will not be there.

Jmeter 2.10 and 2.11 don't let me start a HTTP Script Recorder

I'm having trouble starting a proxy server for jmeter 2.10 and 2.11. I found a couple links here on SO and apache.org but my error message is slightly different that what's written on these links. Per the wiki from apache.org, I don't think I have trouble finding keytool because it returns the path when I do a
which keytool
/usr/bin/keytool
and I don't have trouble creating a file in the jmeter-210 and jmeter-211/bin dirs. This is the error message I get in my jmeter.log file:
ERROR - jmeter.protocol.http.proxy.ProxyControl: Could not initialise key store java.io.IOException: Command :'"keytool" "-genkeypair" "-alias" ":root_ca:" "-dname" "CN=_ DO NOT INSTALL unless this is your certificate (JMeter root CA), OU=Username: COMPANY\user.name, C=US" "-keyalg" "RSA" "-keystore" "proxyserver.jks" "-storepass" "randomstr1" "-keypass" "randomstr1" "-validity" "7" "-ext" "bc:c"' failed, code: 1
keytool error: java.io.IOException: Invalid escaped character in AVA: 's'
I don't know what this "invalid escaped char in AVA" is. My company and username don't have the string "AVA" and I didn't find it in any of the property files in jmeter-21x/bin.
Not sure if this is affecting it but I'm running jmeter from Darwin on a MBP, OSX 10.7.5.
JMeter 2.9 doesn't give me any proxy issues, although, I ran into other issues with it, which is why I tried using these 2 newer versions, which are giving me problems with the proxy server. I'll try going down to 2.8 to see what happens but I'd rather not if I can help it. That and I'm super curious what the issue is with 2.1x and my laptop. Thanks in advance for your help.
EDIT: The COMPANY/user.name part of the error message was changed this way to sanitize the error message, although, I will try at home on my linux box to see if the funny username representation is the cause.
As per sebb response on User Mailing List:
"I suspect it might be in the string "COMPANY\user.name" which is
derived from the Java system property "user.name".
You could try redefining it on the command line (or in
system.properties) to something simpler, for example:
-Duser.name=foobar
A bug has been opened to fix this issue with "\" character:
https://issues.apache.org/bugzilla/show_bug.cgi?id=56178

Handling Waitfor Popup & select window using Ruby Webdriver

When I tried exporting Selenium IDE capture into Ruby - webdriver, I get the following for waitforpopup and select window scenarios.
ERROR: Caught exception [ERROR: Unsupported command [waitForPopUp | | 30000]]
# ERROR: Caught exception [ERROR: Unsupported command [selectWindow | title=TestQA - Des2013 | ]]
How do I handle similar situation using ruby webdriver, as we used to do in selenium RC.
selenium.waitforpopup(windowname, 3000)
selenium.selectWindow(windowname)
Some commands cannot be exported to ruby/rspec scripts.
Is that an overlay? If yes, you can just interact with it with no problem.
Is that another frame? you can use the code below
driver.switch_to.frame "some-frame" # name or id
driver.switch_to.frame driver.find_element(:id, 'some-frame') # frame element
Is that another tab/window? you can use the code below
driver.switch_to.window("<window_handle>")

selenium-server-standalone-2.20.0.jar -userExtensions command line argument throwing error

I was trying to execute selenium ide test suite with the following commandline.
java -jar selenium-server-standalone-2.20.0.jar -userExtensions: "C:\Selenium\user-extensions.js" -htmlSuite "*iexplore" "http://google.com" "C:\Selenium\3" "C:\Selenium\results1.html"
I observed that, without -userExtensions argument above command executes perfectly fine but when i added -userExtensions argument it threw following error,
11:13:39.734 WARN - Embedded iexplore seems to have ended on its own (did we kil
l the real browser???)
Tests failed, see result file for details: C:\Selenium\results1.html
On the other hand if I change the browser to firefox then script stuck at following
11:20:52.296 INFO - Checking Resource aliases.
What is possibly going wrong with the -userExtensions argument.
Help on this would be highly appreciated.
I had the exact same issue. It turned out I had extensions in there that was incompatible with selenium server. Removing those extensions fixed the issue.

Resources