Access java variable inside selenium webdriver javascriptexecutor -


i have int variable in java like

int height = 10; 

i want use java int type variable inside javascriptexecutor of selenium webdriver. have tried in ways shows error time

javascriptexecutor jse = (javascriptexecutor)driver; jse.executescript("var test = '${height}';") 

or

jse.executescript("var test = '<%=height%>';" 

what way use int type variable inside javascriptexecutor of selenium webdriver?

you need use + operator achieve it.

use code below:

webdriver driver=new firefoxdriver(); driver.get("https://www.google.co.in/"); int height=10; string script="alert('"+height+" book not exist');";  javascriptexecutor js=(javascriptexecutor)driver; js.executescript(script);  

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -