我正在尝试使用 xpath 将值填充到文本框(检查下面的图片)。Actions actions = new Actions(driver); actions.moveToElement(driver.findElement(By.xpath("//*[@class='CzI8E']"))); actions.click(); Thread.sleep(3000); actions.moveToElement(driver.findElement(By.xpath("//*[@class='_2S1VP copyable-text selectable-text']")));//_2S1VP copyable-text selectable-text actions.sendKeys(WhatsappConstants.TEXT_MESSAGE); actions.build().perform();但我得到这个例外org.openqa.selenium.WebDriverException: unknown error: ChromeDriver only supports characters in the BMP其他stackoverflow答案说使用firefox驱动程序,但在我的情况下,我只需要使用chrome。
2 回答

交互式爱情
TA贡献1712条经验 获得超3个赞
我有一个类似的问题,我以这种方式解决了它。首先,您应该使用 向此 div 添加任何文本JavascriptExecutor ,然后清除此文本并使用 selenium 的sendKeys方法
WebElement inputDiv = driver.findElement(By.xpath("your_path_to_div"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("document.querySelector('your_selector_to_div').innerText='aaa'");
inputDiv.clear();
inputDiv.sendKeys(subject);
没有找到匹配的内容?试试慕课网站内搜索吧
添加回答
举报
0/150
提交
取消