Headless Chrome - Need help

901 views
Skip to first unread message

Sreeram R

unread,
Dec 29, 2019, 7:09:04 AM12/29/19
to robotframework-users
Hi,

I am trying to run Headless Chrome in the remote pc (open few websites) using Robot Framework

Have the following code.

Open Headless Chrome Browser to Page
    [Arguments]    ${remote_url}
    ${eval_webdriver}    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Create Webdriver    Chrome    chrome_options=${eval_webdriver}
    #Call Method    ${eval_webdriver}    add_argument    test-type
    #Call Method    ${eval_webdriver}    add_argument    --disable-extensions
    Call Method    ${chrome_options}    add_argument    --headless
    #Call Method    ${eval_webdriver}    add_argument    --disable-gpu
    #Call Method    ${eval_webdriver}    add_argument    --no-sandbox
    Open Browser    https://www.makemytrip.com/    Chrome    remote_url=http://192.168.48.201:33344/
    Sleep    ${pageLoadWait}
    Maximize Browser Window
    capture page screenshot
    close browser


When I run this, its not opening the browser in Remote PC, any help please


Dave Amies

unread,
Dec 29, 2019, 10:10:03 PM12/29/19
to robotframework-users
Not sure why you need to do all that? I just do this:


Open Browser about:blank ${BROWSER}
Go To ${MYURL}


where ${BROWSER} is either:
- Headless Firefox
- Headless Chrome


But I don't know about running on a remote PC, can you just run the robot script on the machine you want the test to run from?

According to the doc's I linked that remote_url options is for a Selenium Grid, so I guess you first need to have the selenium grid running on the machine you want to run the test on then from your robot machine run the script that looks like:

Open Browser    https://www.makemytrip.com/  Headless Chrome    remote_url=http://192.168.48.201:33344/

But i've not tried this so have no idea if it'll work, good luck.

Dave.

Aliasger Kiranawala

unread,
Dec 30, 2019, 1:07:06 AM12/30/19
to robotframework-users
Is the issue only with Headless browser? or Chrome browser as well?

Sreeram R

unread,
Dec 30, 2019, 6:06:21 AM12/30/19
to alia...@locus.sh, robotframework-users
I am able to open it on the same machine without any issues but unable to run it on remote desktop

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/68ba869a-1cb3-4630-a180-ac5eab946399%40googlegroups.com.

Aliasger Kiranawala

unread,
Dec 30, 2019, 7:01:58 AM12/30/19
to robotframework-users
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

Sreeram R

unread,
Dec 30, 2019, 11:42:34 AM12/30/19
to alia...@locus.sh, robotframework-users
Hi All,

I am getting the below error. Any help please..


Starting test: VfRobot.Test Case.Juniper CSO.Creating the On Premise Spoke site
20191230 16:40:10.514 :  INFO : ${chrome_options} = <selenium.webdriver.chrome.options.Options object at 0x000001B5899755C8>
20191230 16:40:10.530 :  INFO : Creating an instance of the Chrome WebDriver.
20191230 16:40:11.061 : DEBUG : POST http://127.0.0.1:52239/session {"capabilities": {"firstMatch": [{}], "alwaysMatch": {"browserName": "chrome", "platformName": "any", "goog:chromeOptions": {"extensions": [], "args": ["test-type", "--disable-extensions", "--headless", "--disable-gpu", "--no-sandbox"]}}}, "desiredCapabilities": {"browserName": "chrome", "version": "", "platform": "ANY", "goog:chromeOptions": {"extensions": [], "args": ["test-type", "--disable-extensions", "--headless", "--disable-gpu", "--no-sandbox"]}}}
20191230 16:40:11.061 : DEBUG : Starting new HTTP connection (1): 127.0.0.1:52239
20191230 16:41:11.160 : DEBUG : http://127.0.0.1:52239 "POST /session HTTP/1.1" 500 965
20191230 16:41:11.160 : DEBUG : Finished Request
20191230 16:41:13.192 :  INFO : Cannot capture screenshot because no browser is open.
20191230 16:41:13.192 :  FAIL :
WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist


20191230 16:41:13.192 : DEBUG :
Traceback (most recent call last):
  File "c:\users\sreeramr\appdata\local\programs\python\python37\lib\site-packages\SeleniumLibrary\__init__.py", line 467, in run_keyword
    return DynamicCore.run_keyword(self, name, args, kwargs)
  File "c:\users\sreeramr\appdata\local\programs\python\python37\lib\site-packages\SeleniumLibrary\base\robotlibcore.py", line 102, in run_keyword
    return self.keywords[name](*args, **kwargs)
  File "c:\users\sreeramr\appdata\local\programs\python\python37\lib\site-packages\SeleniumLibrary\keywords\browsermanagement.py", line 336, in create_webdriver
    driver = creation_func(**init_kwargs)
  File "c:\users\sreeramr\appdata\local\programs\python\python37\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "c:\users\sreeramr\appdata\local\programs\python\python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "c:\users\sreeramr\appdata\local\programs\python\python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "c:\users\sreeramr\appdata\local\programs\python\python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "c:\users\sreeramr\appdata\local\programs\python\python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
Ending test:   VfRobot.Test Case.Juniper CSO.Creating the On Premise Spoke site


CODE
Open Headless Chrome Browser to Page
    [Arguments]    ${remote_url}
    #${chrome_options}    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    ${chrome_options}    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys
    Call Method    ${chrome_options}    add_argument    test-type
    Call Method    ${chrome_options}    add_argument    --disable-extensions

    Call Method    ${chrome_options}    add_argument    --headless
    Call Method    ${chrome_options}    add_argument    --disable-gpu
    Call Method    ${chrome_options}    add_argument    --no-sandbox
    Create Webdriver    Chrome    chrome_options=${chrome_options}
    Set Window Size    1920    1080
    Go To    https://www.google.com/
    #Open Browser    https://www.google.com/    HeadlessChrome    remote_url=http://192.168.48.201:44532/
    #Sleep    ${pageLoadWait}
    #Maximize Browser Window
    #capture page screenshot
    #close browser


To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/5abf1bc7-aa06-4146-8c8a-6cfb9a1807fc%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages