我想将java变量传递给javascript ..
这是我的代码的一部分:
String localArray[][] = new String[50000][9];
String strContratoNumero;
for(int i=1; i<10;i++){
strContratoNumero = localArray[i][0];
我试过这个:
((JavascriptExecutor)driver).executeScript("document.getElementById('txtNr_Contrato_Plano_Trab').value=arguments[0]",strContratoNumero.substring(0,9));
但它不起作用。
请告诉我如何通过上述命令中的变量发送值?
PS:我从excel表中获取数据..但不要担心,因为这部分正在运行。
答案 0 :(得分:0)
为什么不使用字符串连接?
((JavascriptExecutor)driver).executeScript("document.getElementById('txtNr_Contrato_Plano_Trab').value='"+strContratoNumero.substring(0,9)+"'");