我的目标是在Jenkins上运行硒登录测试用例。但是在Jenkins上它不起作用,我认为问题在于单击登录按钮和sendkeys()
。 Jenkins无法发送密钥并单击登录按钮。而且,我在Jenkins上没有得到明确的错误消息,确切的错误是什么
硒代码
System.setProperty("webdriver.chrome.driver", "/home/dev2/Downloads/chrome2.46/chromedriver");
WebDriver m1 = new ChromeDriver();
m1.get("https://www.gateway.com/serviceforecasting/index.php?mode=report");
m1.manage().window().maximize();
// LOGIN
m1.findElement(By.xpath(".//input[@id='userEmailID']")).sendKeys("jbg@autods.com.au");
m1.findElement(By.xpath(".//input[@name='userPassword']")).sendKeys("adinjbg");
m1.findElement(By.xpath(".//input[@type='submit']")).click();
Jenkins控制台:
Xvfb starting$ /usr/bin/Xvfb :0 -fbdir /var/lib/jenkins/xvfb-28-..fbdir8052198913172415118
[seffcon] $ /bin/sh -xe /tmp/jenkins2615817096839228288.sh
+ ./cd.sh
[TestNG] Running:
/home/dev2/eclipse-workspace/seffcon/cd.xml
Starting ChromeDriver 2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5) on port 27922
Only local connections are allowed.
===============================================
Suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
Build step 'Execute shell' marked build as failure
答案 0 :(得分:0)
您可以删除“。”从您的xpath中获取,因为其余的代码对我来说看起来还不错 所以登录将是这样
// LOGIN
m1.findElement(By.xpath("//input[@id='userEmailID']")).sendKeys("jbg@autods.com.au");
m1.findElement(By.xpath("//input[@name='userPassword']")).sendKeys("adinjbg");
m1.findElement(By.xpath("//input[@type='submit']")).click();