Search code examples
selenium-chromedriverseleniumbase

WebGL not supported by browser in Seleniumbase


enter image description here

I'm experimenting with the seleniumbase recorder:

    from seleniumbase import BaseCase
    BaseCase.main(__name__, __file__)


    class RecorderTest(BaseCase):
        def test_recording(self):
            self.open("https://my.site")
            self.open_if_not_url("https://my.site/")
            self.click("div#w-node-_34a5347c-0ce5-6d17-2d9f-a58420b1d5a0-f4a1d267 a")
            self.open_if_not_url("https://my.site/users/sign_in")
            self.type('input[name="email"]', "***@gmail.com")
            self.type('input[name="password"]', "***")
            self.click('button:contains("Sign In")')

Itseems to work until, I login and then I get the screenshot. I'm using conda and python 3.12.

The browser opened by the recorder is:

Chrome Version 123.0.6312.105 (Official Build) (64-bit)

How can I get this working?


Solution

  • To enable WebGL in SeleniumBase, use --enable-3d-apis or set enable_3d_apis=True.

    First example:

    from seleniumbase import BaseCase
    BaseCase.main(__name__, __file__, "--enable-3d-apis")
    
    class ThreeJSTests(BaseCase):
        def test_animation(self):
            if self.is_chromium() and not self.enable_3d_apis:
                self.get_new_driver(enable_3d_apis=True)  # --enable-3d-apis
            url = "https://threejs.org/examples/#webgl_animation_skinning_morph"
            self.open(url)
            self.switch_to_frame("iframe#viewer")
            self.sleep(0.8)
            self.click('button:contains("Wave")')
            self.sleep(3)
    

    Second example:

    from seleniumbase import SB
    
    with SB(enable_3d_apis=True, test=True) as sb:
        sb.open("threejs.org/examples/#webgl_animation_skinning_morph")
        sb.switch_to_frame("iframe#viewer")
        sb.set_text_content("#info p", "Hi, I'm Michael Mintz")
        sb.add_css_style("#info p{zoom: 2.54}")
        sb.sleep(0.8)
        sb.click('button:contains("Wave")')
        sb.highlight("#info p")
        sb.select_option_by_text("select", "Idle")
        sb.click('button:contains("ThumbsUp")')
        sb.set_text_content("#info p", "I created SeleniumBase")
        sb.highlight("#info p")
        sb.sleep(0.8)
        sb.click('button:contains("Jump")')
        sb.sleep(1.5)