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

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?