0
I have a Javascript code that is triggered from another python code, in python I created a variable that pulls a json object of the database, and I need to consult this variable to know which report will update with Javascript code
const objeto = {
"ticket1": ["Relatorio BI 1"],
"ticket2": ["Relatorio BI 2"]
}
console.log('Clicker Injected');
const rows=document.querySelectorAll('#artifactContentList .row');
console.log(rows);
rows.forEach(row=>{
objeto.chave1.forEach(valor =>{
if(row.childNodes[4].innerText === valor){
const button = row.children[1].firstChild.children[1]
button.click()
}
})
});
Is there any way to take this variable in python and put it in Javascript, or, there is some way to link Javascript to the database postgresql
Below the call in python script code in java.
PS: The variable coming from the database is stored using the Pandas library
for n,w in workspaces.items():
try:
nav.driver.execute_script(clickerScript)
except Exception as e:
errH.report('Ocorreu erro na atualização do workspace:{n}'.format(n=n),e)
nav.driver.quit()
It is a Python (Selenium) code that runs on script that goes to the Power BI http and updates reports at a certain time.
– user252321
Includes a screenshot of the Python Java code call.
– user252321
I want to add in a json object the names of the reports that have to be updated, and so do the update.
– user252321
Do not use images for code prefer text as it facilitates copy for testing and page readers for visually impaired programmers can not interpret the image.
– Augusto Vasques
Modified.....
– user252321
How can I do this?
– user252321
Okay, but how do I get this value from the other side, inside the javascript?
– user252321
For example in python define
variavel_python = 10
, still a pythonscript_string= f"let varpy = ${variavel_python};"
when injecting the code contained inscript_string
in the javascript context there will be a variablevarpy
the value of which is 10;– Augusto Vasques
Thank you very much Augusto, excellent help!
– user252321
PS: to create multi-line fstring use three quotes
'''
to open and to close. thus:teste = f''' texto de multiplas linhas '''
– Augusto Vasques