rstudio / shinytest

Automated testing for shiny apps
https://rstudio.github.io/shinytest/
Other
225 stars 55 forks source link

Can't change attributes with executeScriptAsync() #434

Open arepsz opened 1 year ago

arepsz commented 1 year ago

So I have a pretty strange issue right now. I want to test my project with shinytest, but I have a datatable in my app that has random values (data-tabsetid). Because of these values, the tests always fail after the first run. Writing the JS script in the source code is not an option, so that's why I tried to put the script in the test. I use the function correctly, tried it with other JS functions and they worked fine. For example:

app$executeScriptAsync('const callback = arguments[0];

const tabsetID = document.getElementById("GLM_RESULTS_TAB");
tabsetID.textContent = "Changed";

callback();')

This does something, obviously it won't change the text in this case because it's a table, but it does something (also it changes the text on the child elements if I apply it on them). On the other hand, if I change the textContent to setAttribute() function, and try to change the "data-tabsetid" attribute to "4321" it doesn't do anything. Am I doing something wrong or is this an issue with the package (or any other package actually)?