I try to create the next expression in codemodel(Sun):
driver.findElement(By.xpath("//div[text()=\""+whatToclick+"\"]/parent::span/parent::span")).click();
so whatToclick would be a parameter in my function.
So I wrote the next:
method.body().invoke(JExpr.ref("driver"), "findElement").arg(jc.ref(By.class).staticInvoke("xpath").arg("//div[text()=\"+"+ whatToclick.name() +"+\"]/parent::span/parent::span")).invoke("click");
and I have two problems:
I don't success to put whatToClick as a parameter. It always in the quotation mark(Because my expression is a string, and I have to put
/"
, otherwise it close the string.)The expression is created without the
click()
part.
Any help?