Handling Waitfor Popup & select window using Ruby Webdriver - ruby

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>")

Related

WebdriverIO: couldn't find executable for firefox browser using default runner (devtools:puppeteer)

I'm using webdriverIO for some automation testing and have recently migrated from 'selenium-standalone' service to default wdio devtools protocol.
wdio v.7.16.12
firefox v.95.0.2
From that point I can't start testing with firefox browser:
INFO #wdio/cli:launcher: Run onPrepare hook
INFO #wdio/cli:launcher: Run onWorkerStart hook
INFO #wdio/local-runner: Start worker 0-0 with arg: run,wdio.conf.js
INFO #wdio/local-runner: Run worker command: run
...
INFO devtools:puppeteer: Initiate new session using the DevTools protocol
ERROR #wdio/runner: Error: Couldn't find executable for browser
...
INFO #wdio/cli:launcher: Run onComplete hook
I've tried different combinations of options with 'wdio:devtoolsOptions' and 'moz:firefoxOptions'.
Plus checked whether could help dumpio: true, and 'moz:debuggerAddress': true options.
Also I've tried substitution browserName with product and adding binary and executablePath to capabilities.
When passing binary: 'path.to.firefox' to 'moz:firefoxOptions' options, the error message changes to:
ERROR #wdio/runner: Error: Only Nightly release channel is supported in Devtools/Puppeteer for Firefox. Refer to the following issue:
...
Any ideas how it could be fixed in webdriverIO (without installing separately puppeteer or puppeteer-firefox)?
Thanks!
Seems that I took desired for real.
wdio + devtools:puppeteer still work with Firefox Nightly only – https://github.com/webdriverio/webdriverio/discussions/7916

Attribute error while executing jmeter script with robotframework

I am trying to execute jmeter with Robot Framework but getting attribute error when I tried to pass extra parameter. I tried below solution but it doesn't work.
How to pass values to the user defined variable in jmeter's jmx file via robot framework
Error:
robot TestCases/TC2_jmeter.robot
==============================================================================
TC2 jmeter
==============================================================================
Get_weather_info | FAIL |
AttributeError: module 'string' has no attribute 'split'
------------------------------------------------------------------------------
TC2 jmeter | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Sounds like usage of a deprecated string function
If you're using this library then it supposed to work with Python 2.7, I think you should be able to still get it, or alternatively identify and re-write the problematic piece of the library, it's open source in any case.
In general you should not need any extra libraries, it's quite possible to kick off a JMeter test in non-GUI mode or generate a HTML Reporting Dashboard using subprocess module

I get an error when using selenium chromedriver to create a session where I am logged into my account

The code I'm using start the session doesn't seem to be working, but I don't know what is wrong with it.
I can create a session without logging in and do what I want but when I try to the use the recommended method of creating the driver with an Options object and adding a user-data-dir, I run into errors.
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('user-data-dir=C:\Users\user\AppData\Local\Google\Chrome\User Data')
driver = Selenium::WebDriver.for(:chrome, options: options)
driver.get("https://login.tripleseat.com/")
email_field = driver["login"]
email_field.send_keys("clshaps93#gmail.com")
email_field.submit
I want my program to get to the bottom section signed into my account without running into an error.
If I don't have a Chrome window already open, I end up with this error:
1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.141.0/lib/selenium/webdriver/remote/response.rb:32:in initialize'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.141.0/lib/selenium/webdriver/remote/response.rb:69:inassert_ok': unknown error: cannot determine loading status (Selenium::WebDriver::Error::UnknownError)
from no such execution context
If I do have Chrome window already open, I end up with this error:
1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.141.0/lib/selenium/webdriver/remote/response.rb:32:in initialize'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.141.0/lib/selenium/webdriver/remote/response.rb:69:inassert_ok': unknown error: Chrome failed to start: crashed (Selenium::WebDriver::Error::UnknownError)
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Other values I have tried to use for user-data-dir just end up being ignored, in that a session starts without logging me in. Is there some code I need to add somewhere to avoid these errors?

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

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')";

Ruby Cucumber: Chrome Driver failed to start

I am trying to Launch chrome browser from Ruby Cucumber framework. But i see it is throwing me an error.
I followed the solutions from stack overflow i.e., to re install chrome application but i see it apparently not working for me.
Here is the code from env.rb file.
require 'selenium-webdriver'
Before do
Selenium::WebDriver::Chrome.driver_path="E:/chromedriver.exe"
$driver=Selenium::WebDriver.for(:chrome)
end
Error is see is as follows.
E:\Eclipse\LoginMercury>cucumber
*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansic
on/) to get coloured output on Windows
Feature: Registration and Login to Mercury Portal
Scenario: Registrating new user in Portal # features/Login.feature:3
unknown error: chrome failed to start
(Driver info: chromedriver=2.3,platform=Windows NT 6.1 x86) (Selenium::WebDr
iver::Error::UnknownError)
./features/support/env.rb:4:in `Before'
Given Load Home page # features/step_definitions/Log
inStep.rb:1
When User need provide Username and password # features/step_definitions/Log
inStep.rb:6
Then Login to Portal # features/step_definitions/Log
inStep.rb:10
Failing Scenarios:
cucumber features/Login.feature:3 # Scenario: Registrating new user in Portal
1 scenario (1 failed)
3 steps (3 skipped)
0m1.180s
As I am using Windows 7, I've tried with older versions of chrome driver even.(V2.3). Yet i failed.
Can someone help me in moving further.
Thanks...!!!!
This is an error when using an older version of the chrome driver such as your version 23 and the latest version of chrome browser.
Upgrade and replace the driver, that your automation path is using for it, to the latest version 27 and this will fix this error.
https://sites.google.com/a/chromium.org/chromedriver/downloads
Cheers.

Resources