Skip to content

Commit

Permalink
Added ability to pass useHostName and secure via openBrowser API and …
Browse files Browse the repository at this point in the history
…bumped version to 1.2.8 for patch release (#2380)

Signed-off-by: Ankur Narkhede <[email protected]>
  • Loading branch information
ankur-lt committed Nov 22, 2021
1 parent e07b474 commit bc30941
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const defaultConfig = {
: process.env.TAIKO_HIGHLIGHT_ON_ACTION || 'true',
blockAlignment: 'nearest',
inlineAlignment: 'nearest',
useHostName: false,
secure: false,
};
const setConfig = (options) => {
for (const key in options) {
Expand Down
2 changes: 2 additions & 0 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const initCRI = async (target, n, options = {}) => {
target,
host: defaultConfig.host,
port: defaultConfig.port,
useHostName: defaultConfig.useHostName,
secure: defaultConfig.secure,
alterPath: defaultConfig.alterPath,
local: defaultConfig.local,
});
Expand Down
4 changes: 4 additions & 0 deletions lib/handlers/targetHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const createdSessionListener = async (client, currentTarget) => {
await cri({
host: defaultConfig.host,
port: defaultConfig.port,
useHostName: defaultConfig.useHostName,
secure: defaultConfig.secure,
alterPath: defaultConfig.alterPath,
local: defaultConfig.local,
target: defaultConfig.browserDebugUrl,
Expand Down Expand Up @@ -191,6 +193,8 @@ const getFirstAvailablePageTarget = async () => {
await cri({
host: defaultConfig.host,
port: defaultConfig.port,
useHostName: defaultConfig.useHostName,
secure: defaultConfig.secure,
alterPath: defaultConfig.alterPath,
local: defaultConfig.local,
target: defaultConfig.browserDebugUrl,
Expand Down
8 changes: 6 additions & 2 deletions lib/taiko.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ module.exports.emitter = descEvent;
* @param {string} [options.host='127.0.0.1'] - Remote host to connect to.
* @param {string} [options.target] - Determines which target the client should interact.(https://github.com/cyrus-and/chrome-remote-interface#cdpoptions-callback)
* @param {number} [options.port=0] - Remote debugging port, if not given connects to any open port.
* @param {number} [options.useHostName=false] - If the browser should be called using the hostname itself or with IP address
* @param {number} [options.secure=false] - HTTPS/WSS frontend. Defaults to false.
* @param {boolean} [options.ignoreCertificateErrors=true] - Option to ignore certificate errors.
* @param {boolean} [options.observe=false] - Option to run each command after a delay. Useful to observe what is happening in the browser.
* @param {number} [options.observeTime=3000] - Option to modify delay time for observe mode. Accepts value in milliseconds.
Expand All @@ -89,6 +91,8 @@ module.exports.openBrowser = async (
if ((options.host && options.port) || options.target) {
defaultConfig.host = options.host;
defaultConfig.port = options.port;
defaultConfig.useHostName = options.useHostName;
defaultConfig.secure = options.secure;
defaultConfig.browserDebugUrl = options.target;
defaultConfig.connectedToRemoteBrowser = true;
} else {
Expand Down Expand Up @@ -1249,7 +1253,7 @@ async function mouseAction(selector, action, coordinates, options = {}) {
* Scrolls the page to the given element.
* The alignment parameters can be overridden, see below.
* Tthe possible values reference are available at the https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.
*
*
*
* @example
* await scrollTo('Get Started')
Expand All @@ -1266,7 +1270,7 @@ async function mouseAction(selector, action, coordinates, options = {}) {
* @param {number} [options.waitForStart = 100] - time to wait for navigation to start. Accepts value in milliseconds.
* @param {string} [options.blockAlignment = 'nearest'] - Defines vertical alignment.
* @param {string} [options.inlineAligment = 'nearest'] - Defines horizontal alignment.
*
*
* @returns {Promise<void>}
*/
module.exports.scrollTo = async (selector, options = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json.schemastore.org/package",
"name": "taiko",
"version": "1.2.7",
"version": "1.2.8",
"description": "Taiko is a Node.js library for automating Chromium based browsers",
"main": "bin/taiko.js",
"bin": {
Expand Down
4 changes: 4 additions & 0 deletions test/unit-tests/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ describe('Config tests', () => {
observeTime: 2,
retryInterval: 2,
retryTimeout: 2,
secure: false,
useHostName: false,
waitForNavigation: false,
waitForEvents: ['firstContentfulPaint'],
criConnectionRetries: 50,
Expand Down Expand Up @@ -244,6 +246,8 @@ describe('Config tests', () => {
observeTime: 5000,
retryInterval: 100,
retryTimeout: 10000,
secure: false,
useHostName: false,
waitForNavigation: true,
waitForEvents: [],
criConnectionRetries: 50,
Expand Down

0 comments on commit bc30941

Please sign in to comment.