Browser not opening in watir webdriver? - watir

I tried to launch "firefox" and "chrome browser" using watir-webdriver, but nothing even for 20 minutes.
I tried:
Watir::Browser.new :firefox
I am using
Jruby
Watir - 0.6.11
Firefox - 33

Related

Codeceptjs - Headless chrome - stepByStepReport enabled - I.switchToNextTab() hangs when the new tab opens a PDF file

"codeceptjs": "^3.0.2"
"#wdio/selenium-standalone-service": "^6.8.0"
"webdriverio": "^6.8.0"
Sample code:
I.amOnPage("https://www.pdfpdf.com/samples.html");
I.click('//a[#href="samples/Sample2.PDF"]');
I.switchToNextTab();
I.closeCurrentTab();
When above code is run in normal mode (non-headless) with or without stepByStepReport enabled, it works fine.
When above code is run with headless mode and stepByStepReport enabled - it hangs at I.switchToNextTab()
Looks like it is not able to take screenshot here
I switch to next tab
ยป Screenshot has been saved to
<>\0002.png
But 0002.png is not found. We have files only till 0001.png
When the code is run with headless mode and stepByStepReport is disabled, then it works fine.
So problem seems to be with:
Headless + stepByStepReport enabled + Link opens a PDF file
Any thoughts or suggestions on this?
It looks like still not supported in headless mode: https://github.com/puppeteer/puppeteer/issues/1872

Switching between browser tabs - Appium

# get current window handle
window_before = self.driver.window_handles[0]
# click on a button which opens a new tab
self.driver.find_element(*EditLocators.preview_button).click()
# wait for new tab to open
self.wait_for_new_tab()
# get the new tab's window handle
window_after = self.driver.window_handles[1]
# switch to new tab
self.driver.switch_to.window(window_after)
"do some actions in new tab"
# close that new tab
self.driver.close()
# switch back to original tab
self.driver.switch_to.window(window_before)
The above is a code snippet of my appium tests of a website in chrome browser, which is being run on a physical device(android). There is a button on web page which opens a new tab. I have to switch between these two tabs, but I am getting this error:
selenium.common.exceptions.WebDriverException: Message: unknown error: 'name' must be a string
(Session info: chrome=69.0.3497.100)
(Driver info: chromedriver=2.38.552522
(437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Linux 4.15.0-38-generic x86_64)
at this line:
self.driver.switch_to.window(window_after)
my appium server version is 1.8.1 and appium python client version is 0.28.
When I printed "window_before" and "window_after" variables the result is CDwindow-0 , CDWindow-1 respectively
Updating appium sever from 1.8.1 to 1.9.1 solved the problem

Python 3.X Selenium Headless Chrome Error 1016

I want to run headless Chrome but it keeps crashing with the following error:
[0814/155351.062:ERROR:gpu_process_transport_factory.cc(1016)] Lost UI shared context.
I have no idea what is going on here. My code is simple and works with the GUI.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless') # Enable headless
options.add_argument('--disable-gpu') # Required as I am on Windows
driver = webdriver.Chrome(chromepath,chrome_options=options) #chromepath is a raw string to the driver
driver.get('https://en.wikipedia.org/wiki/Wiki')
driver.quit()
print('Successfully opened and closed headless Chrome')
All dependencies are current:
Chrome version: 68.0.3440.106(Official Build)(64-bit)
Selenium: 3.14.0
Chromedriver: 2.41

Watir PhantomJS driver optional argument for ignoring SSL errors?

Good day all,
I'm working on automating some Ruby scripts to make them headless. My initial approach
was to try Watir and its PhantomJS module. Our local test environment uses a self-signed
certificate that I know some browser will error out on. I know that PhantomJS has a
ignoreSSLerrors option but don't know how to specify that the PhantomJS driver should use
it. I can create a headless browser phantom-js session without any problem but when I try
to navigate to the webpage using the self-signed certificate, I get nothing - no errors, no
text, no indication of why my page wasn't loaded.
Basically, this is what happens (the odysseyURL was defined elsewhere as a string URL that
Firefox can load without a problem):
irb(main):035:0* driver = Watir::Browser.new :phantomjs
PhantomJS is launching GhostDriver...
[INFO - 2013-12-05T15:48:49.998Z] GhostDriver - Main - running on port 8910
[INFO - 2013-12-05T15:48:50.219Z] Session [bc1bd280-5dc4-11e3-8b99-7bac3d2f1d15]
-_decorateNewWindow - page.settings{"XSSAuditingEnabled":false,
"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"
javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,
"userAgent":"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/534.34 (KHTML, like
Gecko) PhantomJS/1.9.2 Safari/534.34","webSecurityEnabled":true}
[INFO - 2013-12-05T15:48:50.252Z] Session [bc1bd280-5dc4-11e3-8b99-7bac3d2f1d15]
- page.customHeaders: - {}
[INFO - 2013-12-05T15:48:50.262Z] Session [bc1bd280-5dc4-11e3-8b99-7bac3d2f1d15]
- CONSTRUCTOR - Desired Capabilities:{"browserName":"phantomjs","version":"",
"platform":"ANY","javascriptEnabled":true,"cssSelectorsEnabled":true,
"takesScreenshot":true,"nativeEvents":false,"rotatable":false}
[INFO - 2013-12-05T15:48:50.283Z] Session [bc1bd280-5dc4-11e3-8b99-7bac3d2f1d15]
- CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":
"1.9.2","driverName":"ghostdriver","driverVersion":"1.0.4","platform":
"windows-8-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":
false,"databaseEnabled":false,"locationContextEnabled":false,
"applicationCacheEnabled":false,"browserConnectionEnabled":false,
"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,
"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO - 2013-12-05T15:48:50.327Z] SessionManagerReqHand -
_postNewSessionCommand - New Session Created: bc1bd280-5dc4-11e3-8b99-7bac3d2f1d15
=> #<Watir::Browser:0x73fac05c url="about:blank" title="">
irb(main):036:0>
irb(main):037:0* =begin
<en processed and works headless. Everything below is still being modified
irb(main):039:0= =end
irb(main):040:0*
irb(main):041:0* driver.goto(odysseyURL)
=> "about:blank"
irb(main):042:0> puts(driver.text)
=> nil
irb(main):043:0> puts(driver.html)
<html><head></head><body></body></html>
=> nil
I've searched and researched both Watir and Ghostdriver for documentation on anything like this but have found very little and nothing that could help me.
Any assistance will be appreciated,
mpozos
I'm facing same problem through launching watir / phantomjs on https page, with same result
<html><head></head><body></body></html>
So I tried with mechanize to bypass it, but I was facing another problem ..
It was due to ssl certificate. I solve it adding ssl version and 'do not take account of ssl error' in the new instance .. But I still need to solve the main watir problem..
I've found following informations that I will test tonight..
first one, include more informations when launching phantomjs :
switches = ['--proxy=69.106.88.7:60199', '--proxy-auth=username:password123']
browser = Watir::Browser.new :phantomjs, :args => switches
second, phantomjs usage :
Usage: phantomjs [options] script.[js|coffee] [script argument [script argument ...]]
Options:
--load-images=[yes|no] Load all inlined images (default is 'yes').
--load-plugins=[yes|no] Load all plugins (i.e. 'Flash', 'Silverlight', ...) (default is 'no').
--proxy=address:port Set the network proxy.
--disk-cache=[yes|no] Enable disk cache (at desktop services cache storage location, default is 'no').
--ignore-ssl-errors=[yes|no] Ignore SSL errors (i.e. expired or self-signed certificate errors).
so I think to test that solution :
switches = ['--ignore-ssl-errors=yes']
browser = Watir::Browser.new :phantomjs, :args => switches
I will publish results then
edit : I didn't succes with this solution .. I go watir headless directly .. hope this help

Can't debug Watir scripts running under watir-classic (3.4.0)

I am developing Ruby scripts under Watir 4.0.2 so that I can test Internet Explorer under Watir-classic, and
other browsers (e.g., FireFox) under Webdriver.
If I set the environment variable 'WATIR_DRIVER=webdriver' I can breakpoint/debug my code (using
either IE or FireFox) using the RubyMine 5.0 debugger (with ruby-debug-base19x, ruby-debug-ide).
However, when I set 'WATIR_DRIVER=classic' (to test using IE) the debugger process terminates my
session prematurely with the following message:
Fast Debugger (ruby-debug-ide 0.4.17.beta16, ruby-debug-base19x 0.11.30.pre11) listens on 127.0.0.1:51303
....
Process finished with exit code -1073741819
I am running under Windows 7, IE 9 with a current Ruby environment:
Rubymine 5.0 (RM-125.52)
ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
* LOCAL GEMS *
debugger-ruby_core_source (1.1.7)
ruby-debug-base19x (0.11.30.pre11, 0.11.30.pre10)
ruby-debug-ide (0.4.17.beta16, 0.4.17.beta14)
selenium-client (1.2.18)
selenium-webdriver (2.29.0, 2.27.0)
watir (4.0.2 x86-mingw32)
watir-classic (3.4.0)
watir-webdriver (0.6.2, 0.6.1)
Does anywone have any idea what may be happening here?
Could the problem be with the ruby-debug-* gems?
Are there other options to reliably debug Watir scripts under watir-classic?
Thanks in advance for any insights or suggestions.
Bob Barnhart, SAIC

Resources