I am currently trying to test an app using webdriverio and chrome. But the app does not display anything but the images and some borders (??)(see pic). I get the same behaviour also with other websites, so it is not a problem of the app under test. Everything also displays well using other browsers (e.g firefox)
how it displays in chrome browser
Update: after searching a little bit more, I think this has something to do with passing basic auth credentials in the url, because the page I am testing is password protected. I have this in the webdriverio config file:
capabilities: [{
browserName: 'chrome',
chromeOptions: {
args: ['--disable-blink-features=BlockCredentialedSubresources']
}
}]
I am also using selenium-standalone as a service, version 0.0.10, webdriverio version 4.13.1.
In my code I open the page using:
browser.url("https://user:password#mywebsite.com/kontakt/");
Related
I want to test a Chrome extension and to test it I need to have it browse the web randomly and visit random pages for a long period to see if it generates any errors. You need to be logged into the extension, which is why I am not using Selenium for this as I cannot find a way to log into the extension using Selenium.
Is there a way to make Selenium act on an existing or pre-set Chrome existence? Any other options?
You can use web-ext. You can use Firefox, google Chrome, Chromium.
You can script your browser like this.
import webExt from 'web-ext';
webExt.cmd.run({
// These are command options derived from their CLI conterpart.
// In this example, --source-dir is specified as sourceDir.
firefox: '/path/to/Firefox-executable',
sourceDir: '/path/to/your/extension/source/',
}, {
// These are non CLI related options for each function.
// You need to specify this one so that your NodeJS application
// can continue running after web-ext is finished.
shouldExitProgram: false,
})
.then((extensionRunner) => {
// The command has finished. Each command resolves its
// promise with a different value.
console.log(extensionRunner);
// You can do a few things like:
// extensionRunner.reloadAllExtensions();
// extensionRunner.exit();
});
There should be an option to define --start-url. You can make this a random url with some programming... Not able to test it now, but you should be able to make it work
Or you just run from the commandline
web-ext run --start-url www.mozilla.com
I am trying to get control of the existing chrome browser and want to use the same browser for automation, using selenium & Karate.
Here is an actual scenario:
I click a hyperlink from the desktop and it opens in the chrome browser. Now I need to run my automation script in the same browser.
I have the following code, before that, I am starting chrome browser in debugging mode using this link https://harith-sankalpa.medium.com/connect-selenium-driver-to-an-existing-chrome-browser-instance-41435b67affd
* def startUrl = "https://google.com"
* def browser = "chrome"
* def type = "chromedriver"
* def executable = "C:/chromedriver/" + type + ".exe"
* def driverConfig = { type: #(type), showDriverLog: true, start:false, executable: #
(executable), webDriverSession: { desiredCapabilities: { browserName: #
(browser),goog:chromeOptions": { debuggerAddress: 127.0.0.1:9223 } } } }
* configure driver = driverConfig
Given driver startUrl
* waitFor('input[name=q]')
And input('input[name=q]', 'Youtube')
can anyone please confirm how it will be done? I am new to Karate-UI
Getting control of an existing Chrome instance to use Karate UI is only possible if that Chrome instance has been started with remote-debugging enabled.
From the command-line, this is typically done by adding this option: --remote-debugging-port=9222.
I know a team that uses Karate UI for automating CEF (Chromium Embedded Framework) used in a desktop application. In this case, the developers of the desktop app made an environment variable drive the enabling of this debug mode. For e.g. if the OS env variable ENABLE_CHROME_DEBUG had a value equal to true, the CEF remote-debugging would be programmatically enabled via the SDK / API.
So you have to figure out some similar approach. If the desktop app is creating a new instance of Chrome, it should be possible to enable the remote debugging also - and you should work with the development team to make this "switchable" for the sake of testability.
Once that is done, Karate has a way to "attach" to an existing Chrome instance via the remote-debug protocol. Refer the docs: https://github.com/intuit/karate/tree/master/karate-core#configure-driver
And note the attach config key:
optional, only for type: 'chrome' and start: false when you want to attach to an existing page in a Chrome DevTools session, uses a "contains" match against the URL
So if you know the URL that has been opened in the browser you want to attach to (even if it is about:blank) you can now proceed with testing. You will need only these keys in the configure driver data:
type: 'chrome'
start: false
attach: 'some/url' - since this is a "contains" match, the http or https part can be omitted
port: 9222 - change this to use the actual port if different
And executable etc. is not needed.
Be aware of a certain quirk when you combine Desktop and Browser testing: https://github.com/intuit/karate/issues/1549#issuecomment-821265333
I want to run https tests using Protractor nodeJS framework. But my tests expect to pass cert and key.
I looked into Protractor, I could not find any option to pass cert and key.
You should be able to use acceptInsecureCerts field in the capabilities section of your config to get around this. The following example works for chrome and firefox. I'm not entirely sure what it is for other browsers but it will be similar to this.
capabilities: {
browserName: 'chrome',
acceptInsecureCerts : true
}
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