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?
robotframework
add a comment |
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?
robotframework
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
add a comment |
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?
robotframework
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
robotframework
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
add a comment |
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
add a comment |
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.
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
|
show 3 more comments
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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.
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
|
show 3 more comments
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.
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
|
show 3 more comments
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.
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.
edited Nov 12 at 7:17
answered Nov 9 at 13:07
A. Kootstra
4,0742932
4,0742932
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
|
show 3 more comments
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
|
show 3 more comments
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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