Skip to content

Commit

Permalink
[js] Fix running the casting related methods in chromium (#13479)
Browse files Browse the repository at this point in the history
Casting methods call "this.schedule", but it does not exist in the class. Updating the methods to actually execute the commands.
  • Loading branch information
pujagani authored Jan 23, 2024
1 parent f9ff9b3 commit 1e2b8d6
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 18 deletions.
30 changes: 12 additions & 18 deletions javascript/node/selenium-webdriver/chromium.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
}

Expand All @@ -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 + ')'
)
)
}

Expand All @@ -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 + ')'
)
)
}

Expand All @@ -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 + ')'
)
)
}

Expand All @@ -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)
)
}

Expand All @@ -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 + ')'
)
)
}
}
Expand Down
49 changes: 49 additions & 0 deletions javascript/node/selenium-webdriver/test/chrome/cast_test.js
Original file line number Diff line number Diff line change
@@ -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'] }
)

0 comments on commit 1e2b8d6

Please sign in to comment.