How can I keep the browser open after I open it with a python function Open Browser in RobotFramework











up vote
1
down vote

favorite












I have the following python file OpenBrowser.py



from selenium import webdriver
from selenium.webdriver.chrome.options import Options



def openit(browser):

chrome_options = Options()
chrome_options.add_argument("--headless")

desired_capabilities = chrome_options.to_capabilities()
desired_capabilities['acceptInsecureCerts'] = True


driver = webdriver.Chrome()
#driver = webdriver.Chrome("C:Python27Scriptschromedriver.exe", chrome_options=chrome_options,desired_capabilities=desired_capabilities)
driver.get("http://www.python.org")

return browser


and a robot file:



*** Settings ***
Documentation Suite description
Library OpenBrowser.py

*** Test Cases ***
Test title
openit browser


The browser is open, but then it closes and if I want to run another keyword in RF I get error: No brpwser is open



How can I run the python function and keep the browser open?










share|improve this question






















  • Is the commented line in your example of any use? If not, van you remove it for clarity? Can you highlight why you want to open the browser from Python and not use the standard keywords for creating capabilities or the standard functionality for running headless?
    – A. Kootstra
    Nov 9 at 12:09










  • Hello A. Kooststr, yes I will use it in the future. I want to run this python keyword and not the standard one from RF, because I have a website that doesn't have trusted cerificates and I saw that I can open it headless using desired capabilities. But now I stuck because the page that I open with python keyword doesn't remain open. It doesn't behave like Open Browser keyword from RF.
    – mrsmith
    Nov 9 at 12:39












  • No, it's not working to open not even your url. Maybe is something wrong in my setup.
    – mrsmith
    Nov 12 at 9:32















up vote
1
down vote

favorite












I have the following python file OpenBrowser.py



from selenium import webdriver
from selenium.webdriver.chrome.options import Options



def openit(browser):

chrome_options = Options()
chrome_options.add_argument("--headless")

desired_capabilities = chrome_options.to_capabilities()
desired_capabilities['acceptInsecureCerts'] = True


driver = webdriver.Chrome()
#driver = webdriver.Chrome("C:Python27Scriptschromedriver.exe", chrome_options=chrome_options,desired_capabilities=desired_capabilities)
driver.get("http://www.python.org")

return browser


and a robot file:



*** Settings ***
Documentation Suite description
Library OpenBrowser.py

*** Test Cases ***
Test title
openit browser


The browser is open, but then it closes and if I want to run another keyword in RF I get error: No brpwser is open



How can I run the python function and keep the browser open?










share|improve this question






















  • Is the commented line in your example of any use? If not, van you remove it for clarity? Can you highlight why you want to open the browser from Python and not use the standard keywords for creating capabilities or the standard functionality for running headless?
    – A. Kootstra
    Nov 9 at 12:09










  • Hello A. Kooststr, yes I will use it in the future. I want to run this python keyword and not the standard one from RF, because I have a website that doesn't have trusted cerificates and I saw that I can open it headless using desired capabilities. But now I stuck because the page that I open with python keyword doesn't remain open. It doesn't behave like Open Browser keyword from RF.
    – mrsmith
    Nov 9 at 12:39












  • No, it's not working to open not even your url. Maybe is something wrong in my setup.
    – mrsmith
    Nov 12 at 9:32













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have the following python file OpenBrowser.py



from selenium import webdriver
from selenium.webdriver.chrome.options import Options



def openit(browser):

chrome_options = Options()
chrome_options.add_argument("--headless")

desired_capabilities = chrome_options.to_capabilities()
desired_capabilities['acceptInsecureCerts'] = True


driver = webdriver.Chrome()
#driver = webdriver.Chrome("C:Python27Scriptschromedriver.exe", chrome_options=chrome_options,desired_capabilities=desired_capabilities)
driver.get("http://www.python.org")

return browser


and a robot file:



*** Settings ***
Documentation Suite description
Library OpenBrowser.py

*** Test Cases ***
Test title
openit browser


The browser is open, but then it closes and if I want to run another keyword in RF I get error: No brpwser is open



How can I run the python function and keep the browser open?










share|improve this question













I have the following python file OpenBrowser.py



from selenium import webdriver
from selenium.webdriver.chrome.options import Options



def openit(browser):

chrome_options = Options()
chrome_options.add_argument("--headless")

desired_capabilities = chrome_options.to_capabilities()
desired_capabilities['acceptInsecureCerts'] = True


driver = webdriver.Chrome()
#driver = webdriver.Chrome("C:Python27Scriptschromedriver.exe", chrome_options=chrome_options,desired_capabilities=desired_capabilities)
driver.get("http://www.python.org")

return browser


and a robot file:



*** Settings ***
Documentation Suite description
Library OpenBrowser.py

*** Test Cases ***
Test title
openit browser


The browser is open, but then it closes and if I want to run another keyword in RF I get error: No brpwser is open



How can I run the python function and keep the browser open?







robotframework






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 9 at 11:57









mrsmith

61




61












  • Is the commented line in your example of any use? If not, van you remove it for clarity? Can you highlight why you want to open the browser from Python and not use the standard keywords for creating capabilities or the standard functionality for running headless?
    – A. Kootstra
    Nov 9 at 12:09










  • Hello A. Kooststr, yes I will use it in the future. I want to run this python keyword and not the standard one from RF, because I have a website that doesn't have trusted cerificates and I saw that I can open it headless using desired capabilities. But now I stuck because the page that I open with python keyword doesn't remain open. It doesn't behave like Open Browser keyword from RF.
    – mrsmith
    Nov 9 at 12:39












  • No, it's not working to open not even your url. Maybe is something wrong in my setup.
    – mrsmith
    Nov 12 at 9:32


















  • Is the commented line in your example of any use? If not, van you remove it for clarity? Can you highlight why you want to open the browser from Python and not use the standard keywords for creating capabilities or the standard functionality for running headless?
    – A. Kootstra
    Nov 9 at 12:09










  • Hello A. Kooststr, yes I will use it in the future. I want to run this python keyword and not the standard one from RF, because I have a website that doesn't have trusted cerificates and I saw that I can open it headless using desired capabilities. But now I stuck because the page that I open with python keyword doesn't remain open. It doesn't behave like Open Browser keyword from RF.
    – mrsmith
    Nov 9 at 12:39












  • No, it's not working to open not even your url. Maybe is something wrong in my setup.
    – mrsmith
    Nov 12 at 9:32
















Is the commented line in your example of any use? If not, van you remove it for clarity? Can you highlight why you want to open the browser from Python and not use the standard keywords for creating capabilities or the standard functionality for running headless?
– A. Kootstra
Nov 9 at 12:09




Is the commented line in your example of any use? If not, van you remove it for clarity? Can you highlight why you want to open the browser from Python and not use the standard keywords for creating capabilities or the standard functionality for running headless?
– A. Kootstra
Nov 9 at 12:09












Hello A. Kooststr, yes I will use it in the future. I want to run this python keyword and not the standard one from RF, because I have a website that doesn't have trusted cerificates and I saw that I can open it headless using desired capabilities. But now I stuck because the page that I open with python keyword doesn't remain open. It doesn't behave like Open Browser keyword from RF.
– mrsmith
Nov 9 at 12:39






Hello A. Kooststr, yes I will use it in the future. I want to run this python keyword and not the standard one from RF, because I have a website that doesn't have trusted cerificates and I saw that I can open it headless using desired capabilities. But now I stuck because the page that I open with python keyword doesn't remain open. It doesn't behave like Open Browser keyword from RF.
– mrsmith
Nov 9 at 12:39














No, it's not working to open not even your url. Maybe is something wrong in my setup.
– mrsmith
Nov 12 at 9:32




No, it's not working to open not even your url. Maybe is something wrong in my setup.
– mrsmith
Nov 12 at 9:32












1 Answer
1






active

oldest

votes

















up vote
0
down vote













From the top of my head this should allow you to do what you want:



*** Settings ***
Library SeleniumLibrary

Suite Teardown Close All Browsers

*** Test Cases ***
TC
# Options for startin Chrome
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver

Call Method ${chrome_options} add_argument headless
Call Method ${chrome options} add_argument ignore-certificate-errors

# Arguments for starting ChromeDriver
${service_args} Create List
... --verbose
... --log-path=${EXECDIR}/chromedriver.log

Create Webdriver Chrome chrome_options=${chrome_options} service_args=${service_args}

Go To https://self-signed.badssl.com/

Capture Page Screenshot


The service arguments will instruct ChromeDriver to generate a log file for you in the directory where you start Robot Framework. This may help with the analysis.






share|improve this answer























  • Ok, thanks. But now, in my page I have a form and I want to Input Text using the id of the locator. But I get the error that the locator was not found. Or when I write Get Title looks like the title is the name of the robot file...…
    – mrsmith
    Nov 9 at 13:19












  • Is the same situation, after it is open it is closed.
    – mrsmith
    Nov 9 at 13:26










  • Are there any errors?
    – A. Kootstra
    Nov 9 at 13:50










  • Yes: No browser is Open. The problem is that my url doesn't open at all, I can see from the screenshot that is a blank page, something like it couldn't open it, maybe because of the certs.
    – mrsmith
    Nov 9 at 14:38










  • I've updated the example to allow for the generation of ChromeDriver log. Perhaps this helps with your analysis.
    – A. Kootstra
    Nov 12 at 7:17











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',
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%2f53225305%2fhow-can-i-keep-the-browser-open-after-i-open-it-with-a-python-function-open-brow%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








up vote
0
down vote













From the top of my head this should allow you to do what you want:



*** Settings ***
Library SeleniumLibrary

Suite Teardown Close All Browsers

*** Test Cases ***
TC
# Options for startin Chrome
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver

Call Method ${chrome_options} add_argument headless
Call Method ${chrome options} add_argument ignore-certificate-errors

# Arguments for starting ChromeDriver
${service_args} Create List
... --verbose
... --log-path=${EXECDIR}/chromedriver.log

Create Webdriver Chrome chrome_options=${chrome_options} service_args=${service_args}

Go To https://self-signed.badssl.com/

Capture Page Screenshot


The service arguments will instruct ChromeDriver to generate a log file for you in the directory where you start Robot Framework. This may help with the analysis.






share|improve this answer























  • Ok, thanks. But now, in my page I have a form and I want to Input Text using the id of the locator. But I get the error that the locator was not found. Or when I write Get Title looks like the title is the name of the robot file...…
    – mrsmith
    Nov 9 at 13:19












  • Is the same situation, after it is open it is closed.
    – mrsmith
    Nov 9 at 13:26










  • Are there any errors?
    – A. Kootstra
    Nov 9 at 13:50










  • Yes: No browser is Open. The problem is that my url doesn't open at all, I can see from the screenshot that is a blank page, something like it couldn't open it, maybe because of the certs.
    – mrsmith
    Nov 9 at 14:38










  • I've updated the example to allow for the generation of ChromeDriver log. Perhaps this helps with your analysis.
    – A. Kootstra
    Nov 12 at 7:17















up vote
0
down vote













From the top of my head this should allow you to do what you want:



*** Settings ***
Library SeleniumLibrary

Suite Teardown Close All Browsers

*** Test Cases ***
TC
# Options for startin Chrome
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver

Call Method ${chrome_options} add_argument headless
Call Method ${chrome options} add_argument ignore-certificate-errors

# Arguments for starting ChromeDriver
${service_args} Create List
... --verbose
... --log-path=${EXECDIR}/chromedriver.log

Create Webdriver Chrome chrome_options=${chrome_options} service_args=${service_args}

Go To https://self-signed.badssl.com/

Capture Page Screenshot


The service arguments will instruct ChromeDriver to generate a log file for you in the directory where you start Robot Framework. This may help with the analysis.






share|improve this answer























  • Ok, thanks. But now, in my page I have a form and I want to Input Text using the id of the locator. But I get the error that the locator was not found. Or when I write Get Title looks like the title is the name of the robot file...…
    – mrsmith
    Nov 9 at 13:19












  • Is the same situation, after it is open it is closed.
    – mrsmith
    Nov 9 at 13:26










  • Are there any errors?
    – A. Kootstra
    Nov 9 at 13:50










  • Yes: No browser is Open. The problem is that my url doesn't open at all, I can see from the screenshot that is a blank page, something like it couldn't open it, maybe because of the certs.
    – mrsmith
    Nov 9 at 14:38










  • I've updated the example to allow for the generation of ChromeDriver log. Perhaps this helps with your analysis.
    – A. Kootstra
    Nov 12 at 7:17













up vote
0
down vote










up vote
0
down vote









From the top of my head this should allow you to do what you want:



*** Settings ***
Library SeleniumLibrary

Suite Teardown Close All Browsers

*** Test Cases ***
TC
# Options for startin Chrome
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver

Call Method ${chrome_options} add_argument headless
Call Method ${chrome options} add_argument ignore-certificate-errors

# Arguments for starting ChromeDriver
${service_args} Create List
... --verbose
... --log-path=${EXECDIR}/chromedriver.log

Create Webdriver Chrome chrome_options=${chrome_options} service_args=${service_args}

Go To https://self-signed.badssl.com/

Capture Page Screenshot


The service arguments will instruct ChromeDriver to generate a log file for you in the directory where you start Robot Framework. This may help with the analysis.






share|improve this answer














From the top of my head this should allow you to do what you want:



*** Settings ***
Library SeleniumLibrary

Suite Teardown Close All Browsers

*** Test Cases ***
TC
# Options for startin Chrome
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver

Call Method ${chrome_options} add_argument headless
Call Method ${chrome options} add_argument ignore-certificate-errors

# Arguments for starting ChromeDriver
${service_args} Create List
... --verbose
... --log-path=${EXECDIR}/chromedriver.log

Create Webdriver Chrome chrome_options=${chrome_options} service_args=${service_args}

Go To https://self-signed.badssl.com/

Capture Page Screenshot


The service arguments will instruct ChromeDriver to generate a log file for you in the directory where you start Robot Framework. This may help with the analysis.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 at 7:17

























answered Nov 9 at 13:07









A. Kootstra

3,8492932




3,8492932












  • Ok, thanks. But now, in my page I have a form and I want to Input Text using the id of the locator. But I get the error that the locator was not found. Or when I write Get Title looks like the title is the name of the robot file...…
    – mrsmith
    Nov 9 at 13:19












  • Is the same situation, after it is open it is closed.
    – mrsmith
    Nov 9 at 13:26










  • Are there any errors?
    – A. Kootstra
    Nov 9 at 13:50










  • Yes: No browser is Open. The problem is that my url doesn't open at all, I can see from the screenshot that is a blank page, something like it couldn't open it, maybe because of the certs.
    – mrsmith
    Nov 9 at 14:38










  • I've updated the example to allow for the generation of ChromeDriver log. Perhaps this helps with your analysis.
    – A. Kootstra
    Nov 12 at 7:17


















  • Ok, thanks. But now, in my page I have a form and I want to Input Text using the id of the locator. But I get the error that the locator was not found. Or when I write Get Title looks like the title is the name of the robot file...…
    – mrsmith
    Nov 9 at 13:19












  • Is the same situation, after it is open it is closed.
    – mrsmith
    Nov 9 at 13:26










  • Are there any errors?
    – A. Kootstra
    Nov 9 at 13:50










  • Yes: No browser is Open. The problem is that my url doesn't open at all, I can see from the screenshot that is a blank page, something like it couldn't open it, maybe because of the certs.
    – mrsmith
    Nov 9 at 14:38










  • I've updated the example to allow for the generation of ChromeDriver log. Perhaps this helps with your analysis.
    – A. Kootstra
    Nov 12 at 7:17
















Ok, thanks. But now, in my page I have a form and I want to Input Text using the id of the locator. But I get the error that the locator was not found. Or when I write Get Title looks like the title is the name of the robot file...…
– mrsmith
Nov 9 at 13:19






Ok, thanks. But now, in my page I have a form and I want to Input Text using the id of the locator. But I get the error that the locator was not found. Or when I write Get Title looks like the title is the name of the robot file...…
– mrsmith
Nov 9 at 13:19














Is the same situation, after it is open it is closed.
– mrsmith
Nov 9 at 13:26




Is the same situation, after it is open it is closed.
– mrsmith
Nov 9 at 13:26












Are there any errors?
– A. Kootstra
Nov 9 at 13:50




Are there any errors?
– A. Kootstra
Nov 9 at 13:50












Yes: No browser is Open. The problem is that my url doesn't open at all, I can see from the screenshot that is a blank page, something like it couldn't open it, maybe because of the certs.
– mrsmith
Nov 9 at 14:38




Yes: No browser is Open. The problem is that my url doesn't open at all, I can see from the screenshot that is a blank page, something like it couldn't open it, maybe because of the certs.
– mrsmith
Nov 9 at 14:38












I've updated the example to allow for the generation of ChromeDriver log. Perhaps this helps with your analysis.
– A. Kootstra
Nov 12 at 7:17




I've updated the example to allow for the generation of ChromeDriver log. Perhaps this helps with your analysis.
– A. Kootstra
Nov 12 at 7:17


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225305%2fhow-can-i-keep-the-browser-open-after-i-open-it-with-a-python-function-open-brow%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

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)