我正在自动化Web应用程序并且面临一些困难。右键单击在IE中不起作用,但在Chrome中正常工作。
WebElement elem = driver.findElement(By.id(conf.getPropertyValues("RIGHTCLICKTOMODIFY")));
Actions action= new Actions(driver);
action.contextClick(elem).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build().perform();
Thread.sleep(3000);
WebElement button = driver.findElement(By.id(conf.getPropertyValues("RIGHTCLICK_MODIFY_LINK")));
答案 0 :(得分:0)
显然这是一个尚未关闭的open issue。您可以尝试两种可能的解决方法来解决此问题:
通过/usr/local
执行脚本以模拟right-click。
使用#!/usr/bin/python3
import cgitb
import cgi
from zipfile import ZipFile
import sys
# Files to include in archive
source_file = ["/tmp/file1.txt", "/tmp/file2.txt"]
# Name and Path to our zip file.
zip_name = "zipfiles.zip"
zip_path = "/tmp/{}".format(zip_name)
with ZipFile( zip_path,'w' ) as zipFile:
for f in source_file:
zipFile.write(f);
# Closing File.
zipFile.close()
# Setting Proper Header.
print ( 'Content-Type:application/octet-stream; name="{}"'.format(zip_name) );
print ( 'Content-Disposition:attachment; filename="{}"\r\n'.format(zip_name) );
# Flushing Out stdout.
sys.stdout.flush()
bstdout = open(sys.stdout.fileno(), 'wb', closefd=False)
file = open(zip_path,'rb')
bstdout.write(file.read())
bstdout.flush()
修改Internet Explorer的功能,因为浏览器可能不支持一个或多个driver.executeScript(/* Do something */)
功能。请查看here以获取有关此主题的更多见解。
我希望我的回答可以帮到你。