Browser is not opening when running Jenkins as a service










0















I am running my selenium tests in IE in a Windows VM with the help of Jenkins. When running java -jar jenkins.war, my suite is working fine..



But when Jenkins is running as a service, browser is not opening and always it is failing.



I have opened the service properties and given Allow service to interact with desktop.



The alternate way I am running java -jar jenkins.war as a start up.. But this is starting jenkins when I login VM but if some circumstances due to windows patch update if machine gets restarted this is not working until I login the VM which is not i want.



Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome=chromedriverVersion=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73), userDataDir=C:WindowsTEMPscoped_dir6052_18573, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=70.0.3538.102, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=false, acceptInsecureCerts=false, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=]
Session ID: e6ef32b1e294ce9644a5078d9b8bf8c4
Failed ***********
Started InternetExplorerDriver server (32-bit)
2.51.0.0
Listening on port 45007
Only local connections are allowed
org.openqa.selenium.UnhandledAlertException: Modal dialog present:
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'xx-xx-xx', ip: 'xx.xx.xxx.xxx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:45007/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss]
Session ID: dbbe2316-a3b3-4e39-82e3-04dae698ec73
Nov 16, 2018 6:17:43 PM org.openqa.selenium.support.ui.ExpectedConditions findElement
WARNING: WebDriverException thrown by findElement(By.id: txtUserName)
org.openqa.selenium.UnhandledAlertException: Modal dialog present:
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'xxx-xx-xx', ip: 'xx.xx.xxx.xxx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver









share|improve this question
























  • What errors do you see in jenkins console? Adding logs to your question will help others to better understand the problem

    – Vladimir Efimov
    Nov 14 '18 at 13:43











  • I am not seeing any error in the logs

    – ChanGan
    Nov 15 '18 at 9:30











  • It's strange.. if the browser fails to start it should print something in the console. Just to make sure we are on the same page, inside of every jenkins job there is a link to open a console that shows log of the process run by current job

    – Vladimir Efimov
    Nov 15 '18 at 16:29











  • I have attached exception logs.

    – ChanGan
    Nov 16 '18 at 13:01















0















I am running my selenium tests in IE in a Windows VM with the help of Jenkins. When running java -jar jenkins.war, my suite is working fine..



But when Jenkins is running as a service, browser is not opening and always it is failing.



I have opened the service properties and given Allow service to interact with desktop.



The alternate way I am running java -jar jenkins.war as a start up.. But this is starting jenkins when I login VM but if some circumstances due to windows patch update if machine gets restarted this is not working until I login the VM which is not i want.



Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome=chromedriverVersion=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73), userDataDir=C:WindowsTEMPscoped_dir6052_18573, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=70.0.3538.102, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=false, acceptInsecureCerts=false, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=]
Session ID: e6ef32b1e294ce9644a5078d9b8bf8c4
Failed ***********
Started InternetExplorerDriver server (32-bit)
2.51.0.0
Listening on port 45007
Only local connections are allowed
org.openqa.selenium.UnhandledAlertException: Modal dialog present:
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'xx-xx-xx', ip: 'xx.xx.xxx.xxx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:45007/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss]
Session ID: dbbe2316-a3b3-4e39-82e3-04dae698ec73
Nov 16, 2018 6:17:43 PM org.openqa.selenium.support.ui.ExpectedConditions findElement
WARNING: WebDriverException thrown by findElement(By.id: txtUserName)
org.openqa.selenium.UnhandledAlertException: Modal dialog present:
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'xxx-xx-xx', ip: 'xx.xx.xxx.xxx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver









share|improve this question
























  • What errors do you see in jenkins console? Adding logs to your question will help others to better understand the problem

    – Vladimir Efimov
    Nov 14 '18 at 13:43











  • I am not seeing any error in the logs

    – ChanGan
    Nov 15 '18 at 9:30











  • It's strange.. if the browser fails to start it should print something in the console. Just to make sure we are on the same page, inside of every jenkins job there is a link to open a console that shows log of the process run by current job

    – Vladimir Efimov
    Nov 15 '18 at 16:29











  • I have attached exception logs.

    – ChanGan
    Nov 16 '18 at 13:01













0












0








0








I am running my selenium tests in IE in a Windows VM with the help of Jenkins. When running java -jar jenkins.war, my suite is working fine..



But when Jenkins is running as a service, browser is not opening and always it is failing.



I have opened the service properties and given Allow service to interact with desktop.



The alternate way I am running java -jar jenkins.war as a start up.. But this is starting jenkins when I login VM but if some circumstances due to windows patch update if machine gets restarted this is not working until I login the VM which is not i want.



Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome=chromedriverVersion=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73), userDataDir=C:WindowsTEMPscoped_dir6052_18573, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=70.0.3538.102, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=false, acceptInsecureCerts=false, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=]
Session ID: e6ef32b1e294ce9644a5078d9b8bf8c4
Failed ***********
Started InternetExplorerDriver server (32-bit)
2.51.0.0
Listening on port 45007
Only local connections are allowed
org.openqa.selenium.UnhandledAlertException: Modal dialog present:
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'xx-xx-xx', ip: 'xx.xx.xxx.xxx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:45007/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss]
Session ID: dbbe2316-a3b3-4e39-82e3-04dae698ec73
Nov 16, 2018 6:17:43 PM org.openqa.selenium.support.ui.ExpectedConditions findElement
WARNING: WebDriverException thrown by findElement(By.id: txtUserName)
org.openqa.selenium.UnhandledAlertException: Modal dialog present:
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'xxx-xx-xx', ip: 'xx.xx.xxx.xxx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver









share|improve this question
















I am running my selenium tests in IE in a Windows VM with the help of Jenkins. When running java -jar jenkins.war, my suite is working fine..



But when Jenkins is running as a service, browser is not opening and always it is failing.



I have opened the service properties and given Allow service to interact with desktop.



The alternate way I am running java -jar jenkins.war as a start up.. But this is starting jenkins when I login VM but if some circumstances due to windows patch update if machine gets restarted this is not working until I login the VM which is not i want.



Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome=chromedriverVersion=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73), userDataDir=C:WindowsTEMPscoped_dir6052_18573, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=70.0.3538.102, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=false, acceptInsecureCerts=false, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=]
Session ID: e6ef32b1e294ce9644a5078d9b8bf8c4
Failed ***********
Started InternetExplorerDriver server (32-bit)
2.51.0.0
Listening on port 45007
Only local connections are allowed
org.openqa.selenium.UnhandledAlertException: Modal dialog present:
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'xx-xx-xx', ip: 'xx.xx.xxx.xxx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:45007/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss]
Session ID: dbbe2316-a3b3-4e39-82e3-04dae698ec73
Nov 16, 2018 6:17:43 PM org.openqa.selenium.support.ui.ExpectedConditions findElement
WARNING: WebDriverException thrown by findElement(By.id: txtUserName)
org.openqa.selenium.UnhandledAlertException: Modal dialog present:
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'xxx-xx-xx', ip: 'xx.xx.xxx.xxx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver






jenkins selenium-webdriver






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 14:57









Vladimir Efimov

699312




699312










asked Nov 14 '18 at 10:33









ChanGanChanGan

1,92673987




1,92673987












  • What errors do you see in jenkins console? Adding logs to your question will help others to better understand the problem

    – Vladimir Efimov
    Nov 14 '18 at 13:43











  • I am not seeing any error in the logs

    – ChanGan
    Nov 15 '18 at 9:30











  • It's strange.. if the browser fails to start it should print something in the console. Just to make sure we are on the same page, inside of every jenkins job there is a link to open a console that shows log of the process run by current job

    – Vladimir Efimov
    Nov 15 '18 at 16:29











  • I have attached exception logs.

    – ChanGan
    Nov 16 '18 at 13:01

















  • What errors do you see in jenkins console? Adding logs to your question will help others to better understand the problem

    – Vladimir Efimov
    Nov 14 '18 at 13:43











  • I am not seeing any error in the logs

    – ChanGan
    Nov 15 '18 at 9:30











  • It's strange.. if the browser fails to start it should print something in the console. Just to make sure we are on the same page, inside of every jenkins job there is a link to open a console that shows log of the process run by current job

    – Vladimir Efimov
    Nov 15 '18 at 16:29











  • I have attached exception logs.

    – ChanGan
    Nov 16 '18 at 13:01
















What errors do you see in jenkins console? Adding logs to your question will help others to better understand the problem

– Vladimir Efimov
Nov 14 '18 at 13:43





What errors do you see in jenkins console? Adding logs to your question will help others to better understand the problem

– Vladimir Efimov
Nov 14 '18 at 13:43













I am not seeing any error in the logs

– ChanGan
Nov 15 '18 at 9:30





I am not seeing any error in the logs

– ChanGan
Nov 15 '18 at 9:30













It's strange.. if the browser fails to start it should print something in the console. Just to make sure we are on the same page, inside of every jenkins job there is a link to open a console that shows log of the process run by current job

– Vladimir Efimov
Nov 15 '18 at 16:29





It's strange.. if the browser fails to start it should print something in the console. Just to make sure we are on the same page, inside of every jenkins job there is a link to open a console that shows log of the process run by current job

– Vladimir Efimov
Nov 15 '18 at 16:29













I have attached exception logs.

– ChanGan
Nov 16 '18 at 13:01





I have attached exception logs.

– ChanGan
Nov 16 '18 at 13:01












1 Answer
1






active

oldest

votes


















0














Error log states that your test failed because of:



org.openqa.selenium.UnhandledAlertException: Modal dialog present


It happens when some alert appeared and was not properly handled by your test. To fix it you need to add a logic to handle alert before you call a method to look for an element findElement(By.id("txtUserName")). The code might look like this:



try 
Alert alert = driver.switchTo().alert();
System.out.println("Alert appeared. Text= " + alert.getText());
alert.accept();
catch (NoAlertPresentException ignored)
//if alert is not present for some reason we don't want to fail and can continue a test



or you can wrap to a findElement call with a try catch, then close the alert, and try your logic again:



WebElement el;
try
el = findElement(By.id("txtUserName"));
catch (UnhandledAlertException f)
try
Alert alert = driver.switchTo().alert();
System.out.println("Alert appeared. Text= " + alert.getText());
alert.accept();
el = findElement(By.id("txtUserName"));
catch (NoAlertPresentException ignored)
//if alert is not present for some reason we don't want to fail and can continue a test







share|improve this answer

























  • But the same code is working when run Jenkins in a command prompt

    – ChanGan
    Nov 16 '18 at 20:11











  • it's a bit hard to say without the details of alert, but the fact is that in your second case there is some alert that affect your test. if you add a system out print ln with an alert text you will most probably see what the problem is. Please share an alert text - it might help to resolve your issue.

    – Vladimir Efimov
    Nov 17 '18 at 11:25











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298114%2fbrowser-is-not-opening-when-running-jenkins-as-a-service%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Error log states that your test failed because of:



org.openqa.selenium.UnhandledAlertException: Modal dialog present


It happens when some alert appeared and was not properly handled by your test. To fix it you need to add a logic to handle alert before you call a method to look for an element findElement(By.id("txtUserName")). The code might look like this:



try 
Alert alert = driver.switchTo().alert();
System.out.println("Alert appeared. Text= " + alert.getText());
alert.accept();
catch (NoAlertPresentException ignored)
//if alert is not present for some reason we don't want to fail and can continue a test



or you can wrap to a findElement call with a try catch, then close the alert, and try your logic again:



WebElement el;
try
el = findElement(By.id("txtUserName"));
catch (UnhandledAlertException f)
try
Alert alert = driver.switchTo().alert();
System.out.println("Alert appeared. Text= " + alert.getText());
alert.accept();
el = findElement(By.id("txtUserName"));
catch (NoAlertPresentException ignored)
//if alert is not present for some reason we don't want to fail and can continue a test







share|improve this answer

























  • But the same code is working when run Jenkins in a command prompt

    – ChanGan
    Nov 16 '18 at 20:11











  • it's a bit hard to say without the details of alert, but the fact is that in your second case there is some alert that affect your test. if you add a system out print ln with an alert text you will most probably see what the problem is. Please share an alert text - it might help to resolve your issue.

    – Vladimir Efimov
    Nov 17 '18 at 11:25
















0














Error log states that your test failed because of:



org.openqa.selenium.UnhandledAlertException: Modal dialog present


It happens when some alert appeared and was not properly handled by your test. To fix it you need to add a logic to handle alert before you call a method to look for an element findElement(By.id("txtUserName")). The code might look like this:



try 
Alert alert = driver.switchTo().alert();
System.out.println("Alert appeared. Text= " + alert.getText());
alert.accept();
catch (NoAlertPresentException ignored)
//if alert is not present for some reason we don't want to fail and can continue a test



or you can wrap to a findElement call with a try catch, then close the alert, and try your logic again:



WebElement el;
try
el = findElement(By.id("txtUserName"));
catch (UnhandledAlertException f)
try
Alert alert = driver.switchTo().alert();
System.out.println("Alert appeared. Text= " + alert.getText());
alert.accept();
el = findElement(By.id("txtUserName"));
catch (NoAlertPresentException ignored)
//if alert is not present for some reason we don't want to fail and can continue a test







share|improve this answer

























  • But the same code is working when run Jenkins in a command prompt

    – ChanGan
    Nov 16 '18 at 20:11











  • it's a bit hard to say without the details of alert, but the fact is that in your second case there is some alert that affect your test. if you add a system out print ln with an alert text you will most probably see what the problem is. Please share an alert text - it might help to resolve your issue.

    – Vladimir Efimov
    Nov 17 '18 at 11:25














0












0








0







Error log states that your test failed because of:



org.openqa.selenium.UnhandledAlertException: Modal dialog present


It happens when some alert appeared and was not properly handled by your test. To fix it you need to add a logic to handle alert before you call a method to look for an element findElement(By.id("txtUserName")). The code might look like this:



try 
Alert alert = driver.switchTo().alert();
System.out.println("Alert appeared. Text= " + alert.getText());
alert.accept();
catch (NoAlertPresentException ignored)
//if alert is not present for some reason we don't want to fail and can continue a test



or you can wrap to a findElement call with a try catch, then close the alert, and try your logic again:



WebElement el;
try
el = findElement(By.id("txtUserName"));
catch (UnhandledAlertException f)
try
Alert alert = driver.switchTo().alert();
System.out.println("Alert appeared. Text= " + alert.getText());
alert.accept();
el = findElement(By.id("txtUserName"));
catch (NoAlertPresentException ignored)
//if alert is not present for some reason we don't want to fail and can continue a test







share|improve this answer















Error log states that your test failed because of:



org.openqa.selenium.UnhandledAlertException: Modal dialog present


It happens when some alert appeared and was not properly handled by your test. To fix it you need to add a logic to handle alert before you call a method to look for an element findElement(By.id("txtUserName")). The code might look like this:



try 
Alert alert = driver.switchTo().alert();
System.out.println("Alert appeared. Text= " + alert.getText());
alert.accept();
catch (NoAlertPresentException ignored)
//if alert is not present for some reason we don't want to fail and can continue a test



or you can wrap to a findElement call with a try catch, then close the alert, and try your logic again:



WebElement el;
try
el = findElement(By.id("txtUserName"));
catch (UnhandledAlertException f)
try
Alert alert = driver.switchTo().alert();
System.out.println("Alert appeared. Text= " + alert.getText());
alert.accept();
el = findElement(By.id("txtUserName"));
catch (NoAlertPresentException ignored)
//if alert is not present for some reason we don't want to fail and can continue a test








share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 17 '18 at 11:26

























answered Nov 16 '18 at 14:21









Vladimir EfimovVladimir Efimov

699312




699312












  • But the same code is working when run Jenkins in a command prompt

    – ChanGan
    Nov 16 '18 at 20:11











  • it's a bit hard to say without the details of alert, but the fact is that in your second case there is some alert that affect your test. if you add a system out print ln with an alert text you will most probably see what the problem is. Please share an alert text - it might help to resolve your issue.

    – Vladimir Efimov
    Nov 17 '18 at 11:25


















  • But the same code is working when run Jenkins in a command prompt

    – ChanGan
    Nov 16 '18 at 20:11











  • it's a bit hard to say without the details of alert, but the fact is that in your second case there is some alert that affect your test. if you add a system out print ln with an alert text you will most probably see what the problem is. Please share an alert text - it might help to resolve your issue.

    – Vladimir Efimov
    Nov 17 '18 at 11:25

















But the same code is working when run Jenkins in a command prompt

– ChanGan
Nov 16 '18 at 20:11





But the same code is working when run Jenkins in a command prompt

– ChanGan
Nov 16 '18 at 20:11













it's a bit hard to say without the details of alert, but the fact is that in your second case there is some alert that affect your test. if you add a system out print ln with an alert text you will most probably see what the problem is. Please share an alert text - it might help to resolve your issue.

– Vladimir Efimov
Nov 17 '18 at 11:25






it's a bit hard to say without the details of alert, but the fact is that in your second case there is some alert that affect your test. if you add a system out print ln with an alert text you will most probably see what the problem is. Please share an alert text - it might help to resolve your issue.

– Vladimir Efimov
Nov 17 '18 at 11:25


















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298114%2fbrowser-is-not-opening-when-running-jenkins-as-a-service%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党