Skip to content

[🐛 Bug]: selenium seems to override _, breaking another package #12659

Description

@stefanoborini

What happened?

I am facing a very difficult debugging situation, and I'll gather as many information as I can.

We are using a package called shinyMatrix, together with an R shiny application. Everything is quite dynamic, with matrices widgets generated on the fly. We know that shinyMatrix uses, under the hood, Vue.

What I see is that if I run the test under selenium, and only under selenium, I get the following error in Chrome console

image

After some debugging and watch of the _ variable, I found that the following snippet of code seem to remap _ to a different function

image

It's quite hard to say what's going on, because it's all minified. I was able to trace down that file to verbatim code part of the ruby bindings (I am using the python bindings):

grep -r "allowfullscreen allowpaymentrequest" *
rb/lib/selenium/webdriver/atoms/getAttribute.js:<SNIP> {"class":"className",readonly:"readOnly"},dd="allowfullscreen allowpaymentrequest allowusermedia async autofocus autoplay checked compact complete controls declare default defaultchecked defaultselected defer disabled ended formnovalidate hidden indeterminate iscontenteditable ismap itemscope loop multiple muted nohref nomodule noresize noshade novalidate nowrap open paused playsinline pubdate readonly required reversed scoped seamless seeking selected truespeed typemustmatch willvalidate".split(" ");ba("_",function(a,b){var<SNIP>

The resulting effect of the overwrite is that this function in shinymatrix is no longer able to find the lodash utility function cloneDeep:

image

I don't know if this is a selenium problem, a Vue problem, a shiny problem, or a shinyMatrix problem. For now the most likely culprit seems to be selenium, but I might have to investigate further if you have more information about what's going on.

How can we reproduce the issue?

Hard to reproduce without my full code, but I am using a very simple script:

import time
from selenium import webdriver
from uidriver.widgets.shiny import Selector, Tabset

options = webdriver.ChromeOptions()
driver = webdriver.Chrome(options=options)
driver.implicitly_wait(2)
driver.get("http://localhost:8888")
time.sleep(10)
Selector(driver).id("redacted").select("2")
Selector(driver).id("redacted2").select("redacted")
Tabset(driver).index(1).click_tab("redacted")
time.sleep(1000)

The Selector and Tabset are basically classes I developed to simplify the access. In the end, they are fancy wrappers for a find_element with a By.XPATH and click(). The Tabset change should make the shinyMatrix appear, but the error actually occurs already at the point of the second selector.

Relevant log output

See above.

Operating System

macOS 13.5.1

Selenium version

selenium==4.11.2 on python 3.11

What are the browser(s) and version(s) where you see this issue?

Chrome 116.0.5845.110

What are the browser driver(s) and version(s) where you see this issue?

Downloaded by selenium

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions