Chrome中contextClick的替代方案:SeleniumWebDriver-Java

Chrome中contextClick的替代方案:SeleniumWebDriver-Java,java,google-chrome,selenium,selenium-webdriver,selenium-chromedriver,Java,Google Chrome,Selenium,Selenium Webdriver,Selenium Chromedriver,我知道有人可以找到类似的问题,但没有人给出替代的解决方案。请容忍我 经过一些研究,我意识到在Chrome浏览器中不可能自动执行contextClick。例如: 如果我需要执行以下代码和浏览器必须是铬- driver.get("https://www.google.com"); Actions ac= new Actions(driver); ac.moveToElement(driver.findElement(By.id("hplogo"))).contextClick()

我知道有人可以找到类似的问题,但没有人给出替代的解决方案。请容忍我

经过一些研究,我意识到在Chrome浏览器中不可能自动执行contextClick。例如:

如果我需要执行以下代码和浏览器必须是铬-

driver.get("https://www.google.com"); Actions ac= new Actions(driver); ac.moveToElement(driver.findElement(By.id("hplogo"))).contextClick().sendKeys(Keys.ARROW_DOWN).build().perform(); 驱动程序。获取(“https://www.google.com"); 动作ac=新动作(驾驶员); ac.moveToElement(driver.findElement(By.id(“hplogo”))).contextClick().sendKeys(key.ARROW_DOWN).build().perform(); 如果我能找到一个替代使用contextClick选项的方法,那将很有帮助。
感谢使用我的chrome浏览器,contextClick工作正常。尝试下面的代码行,它可能会解决您的问题


ac.moveToElement(driver.findelelement(By.id(“hplogo”)).contextClick().sendKeys(Keys.ARROW_DOWN”).sendKeys(Keys.RETURN.build().perform()

您是否仅尝试执行上下文单击,然后

    Actions conClick=new Actions(driver);

    //i am expecting you are try to perform right click id = hplogo
    conClick.contextClick(driver.findElement(By.id("hplogo"))).build().perform();

    // if you want to select or click any option in this context menu
    // go for click with specific location, no need of keys
    // if required use sleep before click
    driver.findElement(By.id("required location")).click();
若上下文单击后的上面的单击未按预期工作,那个么您也可以尝试下面的方法

        Actions conClick1=new Actions(driver);
    //i am expecting you are try to perform right click id = hplogo
    //after context click moving to 25 vertically, may be second option in context menu and clicking
    conClick1.contextClick(driver.findElement(By.id("hplogo"))).moveByOffset(5, 25).click().build().perform();
谢谢,,
穆拉里

你到底想做什么??什么行动??