上述代码在selenium with java中给出了错误无效字符常量

上述代码在selenium with java中给出了错误无效字符常量,java,selenium,automated-tests,underscore-java,Java,Selenium,Automated Tests,Underscore Java,String wb=driver.findElement(By.xpath(“//div[@class='gb\u h gb\u i']]/a”).getAttribute('href') 上述代码给出错误无效字符常量 我想使用java从html代码中提取href您应该将getAttribute('href')更改为getAttribute('href'),所以应该是 String wb=driver.findElement(By.xpath(“//div[@class='gb\u h gb\u

String wb=driver.findElement(By.xpath(“//div[@class='gb\u h gb\u i']]/a”).getAttribute('href')

上述代码给出错误
无效字符常量


我想使用java从html代码中提取
href
您应该将
getAttribute('href')
更改为
getAttribute('href')
,所以应该是
String wb=driver.findElement(By.xpath(“//div[@class='gb\u h gb\u i']/a”).getAttribute(“href”)
getAttribute()
方法接收
String


在Java中,字符串是由
定义的
而字符是由
定义的
我的回答解决了你的问题了吗?