Skip to content

Instantly share code, notes, and snippets.

@kyroskoh
Created November 9, 2022 08:25
Show Gist options
  • Save kyroskoh/c5f083aa72007fab695cce2ce75f961b to your computer and use it in GitHub Desktop.
Save kyroskoh/c5f083aa72007fab695cce2ce75f961b to your computer and use it in GitHub Desktop.
testcase to create Webdriver as we need to set chrome_options and executable_path (path chromedriver).
*** Settings ***
Library SeleniumLibrary
Test Teardown Close Browser
*** Variables ***
${URL} https://www.google.com
${txtSearch} //*[@name="q"]
*** Test Cases ***
Open Browser
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys
Call Method ${chrome_options} add_argument --disable-dev-shm-usage #disable page crash of chrome
Call Method ${chrome_options} add_argument --no-sandbox #disable sandbox mode
Call Method ${chrome_options} add_argument --headless #run with no web browser
Create Webdriver driver_name=Chrome alias=google chrome_options=${chrome_options} executable_path=/usr/local/bin/chromedriver
Set Window Size 1200 1000 #run on docker can't use Maximize Browser Window
Go To ${URL}
Wait Until Element Is Visible ${txtSearch} 10s
Input Text ${txtSearch} Robotframework
Press Keys ${txtSearch} RETURN
Capture Page Screenshot Robotframework.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment