ChromeDriver didn't exit full screen when performing ESC key from Selenium

194 views
Skip to first unread message

Hermanto Tang

unread,
May 8, 2020, 9:16:35 AM5/8/20
to Selenium Users
HTML file:
<!DOCTYPE html>
<html lang="en">
<body>
    <video width="320" height="240" controls>
        <source src="https://www.w3schools.com/html/movie.mp4" type="video/mp4">
        <source src="https://www.w3schools.com/html/movie.ogg" type="video/ogg">
    </video>
</body>
</html>

JS file:
    it('test', async function() {
        await driver.get('YOUR LOCAL SERVER');

        await driver.sleep(5000);
        // Manually perform fullscreen action

        await driver.actions().sendKeys(Key.ESCAPE).perform();

        await driver.sleep(1000);

        const fullscreenElement = await driver.executeScript(function() {
            return document.fullscreenElement;
        });

        expect(fullscreenElement).to.not.be.exist;
    });


Version: ChromeDriver 81.0.4044.138


When manually press ESC button in my keyboard, it can exit fullscreen. But when perform ESC by sendKeys(), it didn't work.
Not sure if the issue is in selenium or in chromedriver.

Joe Ward

unread,
May 8, 2020, 9:32:11 AM5/8/20
to seleniu...@googlegroups.com
I don’t fully understand why you’d want to do this but 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/0cabb9a1-c407-4912-affa-3307ceccc65a%40googlegroups.com.

HT

unread,
May 9, 2020, 1:13:49 AM5/9/20
to Selenium Users
Nah, I want to create test to simulate user pressing ESC key and make sure our player behavior is responding correctly.
So, simulating ESC key is essential in my case.
To unsubscribe from this group and stop receiving emails from it, send an email to seleniu...@googlegroups.com.

Joe Ward

unread,
May 9, 2020, 4:46:48 AM5/9/20
to seleniu...@googlegroups.com
Ah, OK. In which case it might be because your action is missing the build() step? Eg await driver.actions().sendKeys(Key.ESCAPE).build().perform();


To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e38a1c97-a09f-4bf5-8c81-c734deb01ba7%40googlegroups.com.

Joe Ward

unread,
May 9, 2020, 4:50:04 AM5/9/20
to seleniu...@googlegroups.com
My mistake that isn’t part of the JS class. 

HT

unread,
May 9, 2020, 11:43:32 AM5/9/20
to Selenium Users
Sending ESC keys works actually (did try listen to keyboard event in in JS file and ESC key is captured).
It's just when video is in fullscreen and sending ESC key didn't exit its fullscreen, but when I manually press ESC key, it can exit fullscreen.
Reply all
Reply to author
Forward
0 new messages