I am trying to run my Protractor test on a remote server (selenium grid). I have Jenkin job to execute commands. When I run the exact test on my local server, the browser (both Firefox and Chrome works) get starts and load the URL and complete the tests. But when I execute via Jenkins it starts the browser but does not load the URLs. After some time Jenkins job gets timed out but still, browsers are open and do nothing. any idea? help much appreciated
I am passing the remote server as follows in my config.js,
seleniumAddress:http://citest-grid.com:4444/wd/hub
I managed to solve this issue removing 'disable-infobars' in the chromeOptions. But not sure why
'chromeOptions': {
'args': ['disable-infobars']
}
Check with the below code
capabilities: {
browserName: 'chrome',
directConnect: true //Hope by adding this your problem gets resolved
}
Remove seleniumAddress from your config.
Related
I'm using the --live switch at the end of my command to keep the chrome session live.
testcafe chrome --live
but it just runs my tests, passes and then turns the browser off.
Am I missing anything? Do I need anymore config, etc?
Thanks,
I am using Selenium to open a web site, login and copy some information from one web site. However it is happening on my work station and have a display monitor.
my IT team wants to move this process to a virtual server which does not have a monitor.
1.Will this work - even if we install Chrome of Firefox on the server
2. Can we Chrome - headless to make this happen
3. Any other way - we can think of using Xserver
Please let me know.
No . To run your script you don't need to have monitor. You can access your virtual machine through remote connection and you can start the execution from that machine. Once the execution started, you can close the remote desktop session and execution will continue to run on remote machine or virtual server.
I hope this helps. Please let me know if you have any further questions.
1.Will this work - even if we install Chrome or Firefox on the server - Yes it will work
2.Can we Chrome - headless to make this happen - If you are going to use virtual server just for execution,then you don't need to run in headless mode. Headless execution is needed for environments where you don't need a visible UI shell. Below code will help you run your script in headless mode
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu') # Last I checked this was necessary.
driver = webdriver.Chrome("/usr/local/bin/chromedriver", chrome_options=options)
driver.get("https://google.com")
#code to extract the details
driver.quit()
3.Any other way - we can think of using Xserver - Not sure
Chrome headless should solve your problem here -- I've done this in the past with some of my automation and had success.
Just remember to use ChromeOptions to add the --headless flag. You may need to tweak some other ChromeOptions as well -- I also had to add --disable-gpu and --window-size=1920,1200 to get mine working just right.
Please suggest a method of getting final urls after redirection in an automated way. It has to run on my headless Ubuntu server.
Selenium will only start a browser in headless mode on this server, else error:
opts = FirefoxOptions()
opts.add_argument("--headless")
But this way the .current_url method on a webdriver instance does not get the redirect, whereas on my PC with normal display mode I am getting the redirect correctly.
Solving this with tools other than Selenium would be great, too.
I'm trying to get PhantomJS working with Protractor. I'm currently having an issue with Phantom, but not Chrome, when my code needs to reach a backend endpoint which is kept on a separate server. As such, I would like to test it with the --ignore-ssl-errors option.
Unfortunately, the example config file provided in the Protractor documentation doesn't seem to list any way to pass arguments to the browser. Is this possible?
It turns out the answer was in a closed Protractor issue: https://github.com/angular/protractor/issues/150
You CAN pass arguments to the browser with the phantomjs.cli.args property, which takes an array of arguments. Just add it to the capabilities property in your configuration, in he same location where you specify the browserName:
capabilities: {
browserName: 'phantomjs',
'phantomjs.binary.path': require('phantomjs').path,
'phantomjs.cli.args': ['--web-security=false', '--ignore-ssl-errors=true', '--webdriver-loglevel=DEBUG'],
}
So I wrote a bookmarklet and want to do some functional testing, I used Protractor and I was able to inject my bookmarklet javascript file to it. However since it is hosted locally it is not HTTPS. When I run the test although the js file is injected, I got
VM122:17 Mixed Content: The page at 'https://xxxx' was loaded over HTTPS, but requested an insecure script 'http://localhost:8000/content.js'. This request has been blocked; the content must be served over HTTPS.
Since the browser is newly created every time the test runs I can't set the 'load unsafe script option' for testing.
You could start chromedriver with extra arguments in your Protractor configuration.
capabilities: {
browserName: "chrome",
chromeOptions: {
args: [
"--allow-running-insecure-content"
]
}
}
For a full list of chromedriver arguments, see:
http://www.assertselenium.com/java/list-of-chrome-driver-command-line-arguments/
https://sites.google.com/a/chromium.org/chromedriver/capabilities