From 1e2b8d63237d49644e459674608dde7e2a559c84 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Tue, 23 Jan 2024 16:01:27 +0530 Subject: [PATCH] [js] Fix running the casting related methods in chromium (#13479) Casting methods call "this.schedule", but it does not exist in the class. Updating the methods to actually execute the commands. --- .../node/selenium-webdriver/chromium.js | 30 +++++------- .../test/chrome/cast_test.js | 49 +++++++++++++++++++ 2 files changed, 61 insertions(+), 18 deletions(-) create mode 100644 javascript/node/selenium-webdriver/test/chrome/cast_test.js diff --git a/javascript/node/selenium-webdriver/chromium.js b/javascript/node/selenium-webdriver/chromium.js index 403a06e41e103..5225d0b1cf5ca 100644 --- a/javascript/node/selenium-webdriver/chromium.js +++ b/javascript/node/selenium-webdriver/chromium.js @@ -835,9 +835,8 @@ class Driver extends webdriver.WebDriver { * containing the friendly device names of available cast sink targets. */ getCastSinks() { - return this.schedule( - new command.Command(Command.GET_CAST_SINKS), - 'Driver.getCastSinks()' + return this.execute( + new command.Command(Command.GET_CAST_SINKS) ) } @@ -849,12 +848,11 @@ class Driver extends webdriver.WebDriver { * when the target device has been selected to respond further webdriver commands. */ setCastSinkToUse(deviceName) { - return this.schedule( + return this.execute( new command.Command(Command.SET_CAST_SINK_TO_USE).setParameter( 'sinkName', deviceName - ), - 'Driver.setCastSinkToUse(' + deviceName + ')' + ) ) } @@ -866,12 +864,11 @@ class Driver extends webdriver.WebDriver { * when the mirror command has been issued to the device. */ startDesktopMirroring(deviceName) { - return this.schedule( + return this.execute( new command.Command(Command.START_CAST_DESKTOP_MIRRORING).setParameter( 'sinkName', deviceName - ), - 'Driver.startDesktopMirroring(' + deviceName + ')' + ) ) } @@ -883,12 +880,11 @@ class Driver extends webdriver.WebDriver { * when the mirror command has been issued to the device. */ startCastTabMirroring(deviceName) { - return this.schedule( + return this.execute( new command.Command(Command.START_CAST_TAB_MIRRORING).setParameter( 'sinkName', deviceName - ), - 'Driver.startCastTabMirroring(' + deviceName + ')' + ) ) } @@ -898,9 +894,8 @@ class Driver extends webdriver.WebDriver { * when the mirror command has been issued to the device. */ getCastIssueMessage() { - return this.schedule( - new command.Command(Command.GET_CAST_ISSUE_MESSAGE), - 'Driver.getCastIssueMessage()' + return this.execute( + new command.Command(Command.GET_CAST_ISSUE_MESSAGE) ) } @@ -912,12 +907,11 @@ class Driver extends webdriver.WebDriver { * when the stop command has been issued to the device. */ stopCasting(deviceName) { - return this.schedule( + return this.execute( new command.Command(Command.STOP_CASTING).setParameter( 'sinkName', deviceName - ), - 'Driver.stopCasting(' + deviceName + ')' + ) ) } } diff --git a/javascript/node/selenium-webdriver/test/chrome/cast_test.js b/javascript/node/selenium-webdriver/test/chrome/cast_test.js new file mode 100644 index 0000000000000..02251d0fdb308 --- /dev/null +++ b/javascript/node/selenium-webdriver/test/chrome/cast_test.js @@ -0,0 +1,49 @@ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +'use strict' + +const assert = require('assert') +const chrome = require('../../chrome') +const test = require('../../lib/test') +const { ignore } = require('../../lib/test') +const { Browser } = require('../../index') + +test.suite( + function (env) { + let driver + + beforeEach(async function () { + driver = await env + .builder() + .build() + }) + afterEach(async () => await driver.quit()) + describe('can cast to devices', () => { + it( + 'get sinks returns a list of devices', + async function () { + + // Just testing if we can set get cast sink command. + // Testing this is tough because we need a device to cast to for the test. + const castSinks = await driver.getCastSinks() + } + ) + }) + }, + { browsers: ['chrome'] } +)