0

My aim is to run the selenium login test case on Jenkins. but on the Jenkins it's not working I think the problem is with clicking on the login button and sendkeys(). the Jenkins is not able to send the Keys and click on the login button. also, I am not getting the clear error message on Jenkins for what is the exact error

selenium code

 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("[email protected]");
m1.findElement(By.xpath(".//input[@name='userPassword']")).sendKeys("adinjbg");

m1.findElement(By.xpath(".//input[@type='submit']")).click();

Jenkins console:

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
7
  • you didnt add any logs in your test thats why its hard to debug your code. Now, do your test work locally fine? if yes, are you running your test in jenkins from localhost of in different server? If you are running on local host , do the browser open fine ?
    – mbn217
    Mar 5, 2019 at 16:06
  • I am able to run the test cases like taking a screenshot and checking the text visibility on the web page. the issue is i don't know whether the Jenkins is able to send the login detail and click on the button. Mar 6, 2019 at 4:59
  • right now i am using the ip address as url for the jenkins . do i need to replace it with localhost to run the test localy . Mar 6, 2019 at 5:01
  • How can I open the browser when I run the test from Jenkins. if u have any idea about it please clarify Mar 6, 2019 at 5:05
  • If you are using remote webdriver , you are technically running your test in a different server. but if you are using regular webdriver then you can run your test from jenkins and see your browser opening and do the tasks. Now can you share you webdriver code so i can see how you are opening the browser in selenium?
    – mbn217
    Mar 6, 2019 at 14:13

1 Answer 1

0

can you remove the "." from your xpath because the rest of the code looks fine to me so the login will be like this

// LOGIN
m1.findElement(By.xpath("//input[@id='userEmailID']")).sendKeys("[email protected]");
m1.findElement(By.xpath("//input[@name='userPassword']")).sendKeys("adinjbg");

m1.findElement(By.xpath("//input[@type='submit']")).click();
1
  • still not working .when I run the build it's getting failed within a second. i think its not even launching the browser screenshot -prnt.sc/naxg85 Apr 12, 2019 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.