Skip to content

Instantly share code, notes, and snippets.

@sotayamashita
Last active February 28, 2024 03:59
Show Gist options
  • Save sotayamashita/4a9955ada8f758fa61775aa09a76dd0f to your computer and use it in GitHub Desktop.
Save sotayamashita/4a9955ada8f758fa61775aa09a76dd0f to your computer and use it in GitHub Desktop.
Robot Framework Cheatsheet

with Browserstack

*** Settings ***
Library           SeleniumLibrary

*** Variables ***
${USERNAME} = 
${ACCESS_KEY} = 
${REMOTE_URL} = http://${USERNAME}:${ACCESS_KEY}@hub.browserstack.com/wd/hub
${BROWSER} = IE
${DC} = os:Windows,os_version:10,browser:${BROWSER},browser_version:11.0,browserstack.local:true

*** Test Cases ***
Main Test Case
    Open Browser   url=https://www.nytimes.com/    browser=${BROWSER}    remote_url=${REMOTE_URL}    desired_capabilities=${DC}
    Capture Page Screenshot

Create Webdriver with Firefox

*** Keywords ***
Open Firefox Browser
    [Documentation]  Create the object which to instantiate the Firefox browser.
    ${firefox_options}=    Evaluate    sys.modules['selenium.webdriver'].FirefoxOptions()    sys, selenium.webdriver
    Create Webdriver    Firefox    firefox_options=${firefox_options}   executable_path=/path/to/geckodriver

You can see other capabilities options below:

Create Webdirver with Chrome

*** Keywords ***
Open Chrome Browser
    [Documentation]  Create the object which to instantiate the Chrome browser.
    ${chrome_options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${chrome_options}    add_argument    --no-sandbox
    Call Method    ${chrome_options}    add_argument    headless
    Create Webdriver    Chrome    chrome_options=${chrome_options}    executable_path=/path/to/chromedriver

You can see other capabilities options below:

@aca6nisa
Copy link

Hi, I try using and got this error
image

image
Can you please help..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment