在firefox quantum上使用selenium 3.5选择WebElement后,我一直在尝试按(CTRL + ALT + 'f')。这是我写的代码:
WebElement ele = m_driver.findElement(By.cssSelector(".tm-project-name"));
ele.click();
Actions act = new Actions(m_driver);
act.sendKeys(Keys.CONTROL).perform();
act.sendKeys(Keys.ALT).perform();
act.sendKeys("f").perform();为了完成这项工作,我也尝试了这种方法
act.sendKeys(Keys.chord(Keys.CONTROL, Keys.ALT, "F")).build().perform();这两种方法在chrome浏览器上都运行得很好,但在firefox quantum上却不起作用。在这个问题上,有人能帮我吗?
发布于 2018-01-18 23:31:15
您可以尝试使用Robot class传递control+Alt+"f“,这将在所有浏览器中工作。
尝试下面的代码。
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_F);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_ALT);
robot.keyRelease(KeyEvent.VK_F);希望这对你有用。
发布于 2018-01-19 04:25:48
WebElement ele = m_driver.findElement(By.cssSelector(".tm-project-name"));
ele.send_keys(Keys.SHIFT+Keys.CONTROL+'f');我通常用python编写,在submitted...Python工作之前我会在集成开发环境中检查它……以为这是C#版本
https://stackoverflow.com/questions/48322229
复制相似问题