Error: NO browser is open

Hello guys,

I´m learning how to use Robot framework and while trying to execute my project it shows a message error.

I´ve done a project to open the browser in a page, login in this page, open an specific menu, then insert information in 2 fields and click in “search”

It will show the correct information, but I wanted to be sure so I inserted this:

Check if the information is correct

SeleniumLibrary.Element Text Should Be    xpath=//td[contains(text(), "O BOTICARIO")]    O BOTICARIO   

But is gives back the message error:

“No browser is open”.


I´m using the “New page” Keyword from Browser library.

and in my settings I have both librarys:

Library Browser
Library SeleniumLibrary

Thank you very much
:blush:

Hi Nathalia,

If you opened the browser with Browser Library keywords then you won’t be able to use SeleniumLibrary keyword on that browser session as SeleniumLibrary can only interact with browsers that SeleniumLibrary opened and vice versa Browser Library can only interact with browsers that Browser Library opened.

You will need to chose one or the other and use that for all the steps in your test case.

FYI the Browser Library equivalent is probably using an assertion with Get Text

${text} =    Get Text    xpath=//td[contains(text(), "O BOTICARIO")]    ==    BOTICARIO

Dave.

2 Likes

Thank you very much Dave,

It helped me a lot, now it’s not showing the error anymore.
Only shows that it has more 2 elements equal, but I´m going to check it.

:blush: :smile:

I’m getting no browser open with this ci=ode can someone plz help
*** Settings ***
Library SeleniumLibrary
Resource …/…/Tests/Env.robot
Resource Navigation.robot
Library BuiltIn

*** Variables ***
${TopLoadBar} xpath://html/body/ui-view/div/md-progress-linear
${TopPageTitle} xpath://html/body/ui-view/div/md-toolbar/div/div[1]
${default_selenium_speed} 0
#try
${options} add_argument=–start-maximized
#${remote_url} http://localhost:4444/wd/hub
${remote_url} http://localhost:4444/wd/hub
${timeout} 10 seconds
${browser} chrome
#${env} Production
#${BaseUrl.Production} https://www.google.com
#changed by me
#${options}= Evaluate sys.modules[‘selenium.webdriver’].ChromeOptions() sys, selenium.webdriver
#${chrome_options}= Evaluate sys.modules[‘selenium.webdriver’].ChromeOptions() sys, selenium.webdriver
#${options} Evaluate sys.modules[‘selenium.webdriver’].ChromeOptions() sys, selenium.webdriver
${chrome_options} Create Dictionary add_argument=–start-maximized
*** Keywords ***

Login

Login as admin
#Login as ${user}
Set Selenium Implicit Wait    ${Implicit_wait}

Login as ${user}

#original ${chrome_options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
# original run keyword if  ${Run_In_Docker}  Call Method    ${chrome_options}    add_argument    --headless
                                    #options.add_argument('--headless')

#####################
${chrome_options}= Evaluate sys.modules[‘selenium.webdriver’].ChromeOptions() sys, selenium.webdriver
Run Keyword if ${Run_In_Docker} Call Method ${chrome_options} add_argument --headless
… ELSE Call Method ${chrome_options} add_argument --start-maximized
Call Method ${chrome_options} add_argument --disable-gpu
#Call Method ${chrome_options} add_argument --start-maximized
Call Method ${chrome_options} add_argument --disable-notifications
Call Method ${chrome_options} add_argument --ignore-certificate-errors-spki-list
Call Method ${chrome_options} add_argument --ignore-certificate-errors
Call Method ${chrome_options} add_argument --ignore-ssl-errors
Call Method ${chrome_options} add_argument --allow-insecure-localhost
Call Method ${chrome_options} add_argument --ignore-urlfetcher-cert-requests

#######
${options}= Evaluate sys.modules[‘selenium.webdriver’].ChromeOptions() sys
Call Method ${options} add_argument --start-maximized

``${capabilities}= Create Dictionary browserName=chrome browserVersion=116 chromeOptions=${options}

${options}=     Call Method     ${chrome_options}    to_capabilities

run keyword if  ${Run_In_Docker}   OPEN BROWSER    ${BaseUrl.${env}}    browser=${browser}   remote_url=http://localhost:4444/wd/hub     options=${capabilities}
...            ELSE    OPEN BROWSER    ${BaseUrl.${env}}  ${browser}   options=${chrome_options}

set window size    1900  1080

#######original try
${executor} = Evaluate sys.modules[‘selenium.webdriver’].remote.remote_connection.RemoteConnection(‘${remote_url}’) sys, selenium.webdriver.remote.remote_connection
${webdriver}= Create Webdriver Chrome options=${chrome_options}

${options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys
Call Method    ${options}    add_argument    --start-maximized

${capabilities}=    Create Dictionary    browserName=chrome    browserVersion=116    chromeOptions=${options}

Open Browser    ${BaseUrl}.${env}    ${browser}    remote_url=${remote_url}    options=${capabilities}

#Open Browser in Headless Mode

#Run Keyword If ${Run_In_Docker} Call Method ${chrome_options} add_argument --headless

#kadach ane on karai
#Call Method    ${webdriver}    set_command_executor    ${executor}
#test_selenium_server_available
Run Keyword If    ${Run_In_Docker}    OPEN BROWSER    ${BaseUrl.${env}}    browser=${browser}   remote_url=${remote_url}     options=${chrome_options}
   ...           ELSE        OPEN BROWSER    ${BaseUrl.${env}}  ${browser}   options=${chrome_options}


Set Window Size    1900  1080
maximize browser window
#wait until element is visible   id:username-input
#input text    id:username-input  ${${user}_name.${env}}
#input text    id:password-input  ${${user}_password.${env}}
#sleep   2seconds
#wait until element is visible    //input[@id="username-input-ldap"]    ${${user}_name.${env}}
Input Text    //input[@id="username-input-ldap"]    ${${user}_name.${env}}
#sleep    3seconds
wait until element is visible    //md-input-container[@class="md-block ng-scope md-tb-dark-theme md-icon-left md-input-focused md-input-has-value"]
Click Element    //md-input-container[@class="md-block ng-scope md-tb-dark-theme md-icon-left md-input-focused md-input-has-value"]
Input Text    //input[@id="password-input"]    ${${user}_password.${env}}
Click Element    //div[@id="toast-parent"]
Click Element    //button[@class="md-raised md-button md-ink-ripple md-tb-dark-theme"]
Press keys    xpath://button[@type='submit']    RETURN
#wait until element is not visible    id:password-input    timeout=${Explicit_wait.l}
 sleep    3seconds
##wait until element is not visible    id="password-input"    timeout=${Explicit_wait.l}
Click Element    //div[@class="md-container md-ink-ripple"]
Click Element    //button[@class="md-raised md-button md-ink-ripple md-tb-dark-theme"]
wait until element is not visible    @id="password-input"    timeout=${Explicit_wait.l}
sleep    3seconds
wait until element is not visible    ${TopLoadBar}
run keyword if      "${user}"=="sys_admin"      Go to Dashboard Page

sleep    3seconds
wait until element is visible   xpath://*[@id="tb-vertical-container"]
page should contain    dashboard

Take a screen shots LoginPage