Selenium XHR ERROR: Response_Code = -1 - selenium

I am using the newest version of Selenium RC and firefox 3.5 When I run my test from eclipse I get this error XHR ERROR: Response_Code = -1 Error_Message = Request Error.
Firefox and Selenium RC open up fine, it seems to try to connect to the remote site I want, but then firefox crashes, any ideas?

I'm pretty sure this is an issue fixed in trunk (and will come out in the pending 1.0.4 release). If you download 2.0a5, this includes a 1.0.x compatible Selenium server. You should be able to drop the -standalone JAR in place and have it work. If not, building from trunk is your next best bet.
Alternatively, you could try to modify the open command call. In dynamic languages, such as Ruby, this is fairly straightforward. open() takes a URL and a boolean as its values. You'll want to invert the logic for the second param (I think it's false by default, so you'll want true).

Related

Selenium and Chromedriver on Lambda - Inconsistency at scale

I have a basic selenium script running/deployed on aws lambda.
Chrome and chromedriver and installed as layers (and available on /opt) via serverless.
The script works ... but only some of the time and rarely at scale (invoking more than 5 instances asynchronously).
I invoke the function in a simple for loop (up to about 200 iterations)
response = client.invoke(
FunctionName='arn:aws:lambda:us-east-1:12345667:function:selenium-lambda-dev-hello',
InvocationType='Event', #|'RequestResponse'|'Event' (async)| DryRun'
LogType='Tail',
#ClientContext='string',
Payload=event_payload,
#Qualifier='24'
)
Other runs, the process hangs while initiating the selenium driver on this line
driver = webdriver.Chrome('/opt/chromedriver_89', chrome_options=options)
other iterations the drivers fail/throw a 'timeout waiting for renderer exception'
This I believe is often due to a mismatch of chromedriver/chrome. I have checked and verified my versions are matched up and compatible (and like i said they do work sometimes).
I guess i'm looking for some ideas/direction to even begin to troubleshoot this. I was under the impression that each invokation of a lambda function is in a separate environment, so why would increasing the volume of invokations have any adverse effect on how well my script runs?
Any ideas or thoughts would be greatly appreciated all!
Discussed in the comments.
There's no complete solution but what has helped improve the situation was increasing the memory of the Lambda service.
The alternatives to try/consider:
Don't use Chrome. Use requests and lxml to query the pages via the network level and remove the need for Chrome.
I did something similar to support another stack question recently. You can see it's similar but not quite the same.
Go to a url and get some text from an xpath:
from lxml import html
import requests
import json
url = "https://nonfungible.com/market/history"
response = requests.get(url)
page = html.fromstring(response.content)
datastring = page.xpath('//script[#id="__NEXT_DATA__"]/text()')
Don't use Chrome. Chrome is ideal for functional testing - but if that's not you objective consider using HtmlUnitDriver or phantomjs. Both of these are significantly lighter than chrome and won't require a browser to be installed (you can run it straight from libraries)
You only need to change the driver initialisation and the rest of the script (in theory) should work.
PhantomJS:
$ pip install selenium
$ brew install phantomjs
from selenium import webdriver
driver = webdriver.PhantomJS()
Unit Driver:
from selenium import webdriver
driver = webdriver.Remote(
desired_capabilities=webdriver.DesiredCapabilities.HTMLUNIT)

getAttribute("value") doesn't work with driver 91.0.4472.19 and Chrome 91.0.4472.77

After Chrome and driver update to 91th version I found the VBA macro with driver 91.0.4472.19 (win32) become return empty string ("") from input tag 'value' attribute:
Dim ch As SeleniumWrapper.WebDriver
Dim el As WebElement
' some code here ...
ch.findElementById("htmlLoginId").SendKeys login
Set el = ch.findElementById("htmlLoginId")
txt = el.getAttribute("value")
With older driver version 90.0.4430.24 this works fine. Hope it will be fixed in next driver versions.
Is there another way to get value from input[type=text] tag? I want to avoid situation if this bug will not be fixed in 92th version and 90th driver version become incompatible.
We have been fighting with this issue a couple of days since the new chrome driver came out. A workaround we did was to bypass calls to the webdriver's getAttribute method if we want to retrieve properties (that are not html attributes) of the element and instead use the following custom script:
browser.executeScript(`return arguments[0].${this.textAttribute}`, el);
The above example is valid for protractor, which is what we are using. If your stack is different, you need to call the appropriate alternative to browser.executeScript, but the script itself would be quite the same.
We did it!
ARG CHROME_VERSION="90.0.4430.212-1"
RUN wget --no-verbose -O /tmp/chrome.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb \
&& apt install -y /tmp/chrome.deb \
&& rm /tmp/chrome.deb
./webdriver-manager update --versions.chrome 90.0.4430.24
This was a regression in chrome driver 91. A fix has been made. Hopefully an updated v91 chrome driver will be released soon.
https://bugs.chromium.org/p/chromium/issues/detail?id=1205107
In the meantime we are using chrome driver 90.
I am reproducing this doing getAttribute('innerHTML') as well. As another workaround, run tests with Firefox instead of Chrome
We are also facing the similar issue while getting attribute data of an element using GetAttribute() of web element in C#. Struggled two days to find out what the root cause is. And for us it is not possible to make workarounds as code base is already frozen. Waiting for the fix. And as per the issue https://bugs.chromium.org/p/chromium/issues/detail?id=1205107 it may take couple of weeks to release another version with fix.
The issue has been fixed with the new release of ChromeDriver 91.0.4472.101 and ChromeDriver 92.0.4515.43

Which version of marionette_driver with Firefox 52.9.0esr (Tor Browser 7.5.6)

The Tor Browser updated to 7.5.6. The previously working code failed with
InvalidSessionIdException:
After updating to marionette_driver 2.7, the call to client.start_session() failed with
marionette_driver.errors.UnknownCommandException: WebDriver:NewSession
Which version of the marionette_driver should be used with this Firefox version? (Or maybe another framework like Selenium?)
Since there are only a few version at Pypi, and no other answer seems to exist, just try them all starting with the current one.
It worked with version 2.5:
pip2 install marionette_driver==2.5
UPDATE: The InvalidSessionIdException returned. To fix this, call client.start_session() again (it can be called when catching the exception in a try-block)

Selenium test tryingnto use firefox instead of chrome

I have the following in my selenium-webdriver test (the test is written as coffee-script):
#driver = new selenium.Builder()
.withCapabilities(selenium.Capabilities.chrome())
.build()
Yet when I run this test the error I get is:
Error: Failed to install profile; firefox terminated with Result(code=-1073
741819, signal=null)
I am perplexed why its trying to start firefox (there is no reference to firefox in my code). Also, at one point this was working. I am not sure what changed in my laptop which has resulted in this behavior.
Thanks for any help.

PhantomJS and SlimerJS fail to render some sites

I didn't get any output file (image) when trying to execute render_multi_url.js in phantomjs or slimerjs for some url like:
www.tamasoft.co.jp/en/general-info/unicode.html
www.bbc.co.uk
I am using the latest version of both phantomjs and slimerjs. render_multi_url.js is the original script shipped with phantomjs. Under slimerjs I get no image at all and under phantomjs I get partial image (over 9mb). Why do I get this behavior?
So what I need to change or improve to get this script working on any web page?
The root cause of the issue, that SSL3 (used by default in P-js) was changed to TLS1 (or better use 'any').
To fix that you should specify the SslProtocol option.
This is the way for c#:
var service = PhantomJSDriverService.CreateDefaultService(driverPath);
service.SslProtocol = "any"
In command line you can use
--ssl-protocol='any'