Home > front end >  selenium.common.exceptions.JavascriptException: Message: ReferenceError: variable is not defined
selenium.common.exceptions.JavascriptException: Message: ReferenceError: variable is not defined

Time:07-31

'    ct1 = df2[(df2['HomeTeam'] == at1)]['AwayTeamScore'].to_string(index=False)
result_away = np.round(ct1, decimals=3)'

output: '0.938031'

When executing the below code,

'javaScript1 = "document.getElementById('PoissonForm_homeGoalExp').value = result_away"'

output:

selenium.common.exceptions.JavascriptException: Message: ReferenceError: result_away is not defined

How can I able to send the value as correctly defined as 'result_away'?

CodePudding user response:

You can execute the javascript using execute_script.

javaScript1 = f"document.getElementById('PoissonForm_homeGoalExp').value = {result_away}"
driver.execute_script(javaScript1)
  • Related