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

xml - Extract substrings with XSLT -

math - "ELO Rating" and how does "TSR Rating" work? -

How can do a tuple comparison in coffeescript similar to that in python? -