Even if I looked it up, it didn't come out easily, so I made a note. (Please tell me if there is a better way)
--Read the URL list from an external file (list.tsv) --Take screenshots for them --Take a full page --Put a line into a python variable and turn it
screen_shot.robot
*** Settings ***
Library SeleniumLibrary
Variables ./import.py
*** Keywords ***
Create Chrome Driver
${options} = Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys
Call method ${options} add_argument --headless
Create webdriver Chrome chrome_options=${options}
*** Test Cases ***
keyword
Create Chrome Driver
${w} = Execute JavaScript return document.body.scrollWidth
${h} = Execute JavaScript return document.body.scrollHeight
Set Window Size ${w} ${h}
Set ScreenShot Directory path=screenshot
${length}= Get Length ${conditions}
:FOR ${idx} IN RANGE ${length}
\ Go To @{urls}[${idx}]
\ Capture Page Screenshot filename=@{conditions}[${idx}].png
import.py
import csv
with open('list.tsv') as f:
reader = csv.reader(f, delimiter='\t')
l = [row for row in reader]
l_T = [list(x) for x in zip(*l)]
conditions = l_T[0]
urls = l_T[1]
list.tsv
Cat https://www.google.com/search?q=%E3%81%AD%E3%81%93&tbm=isch
Dog https://www.google.com/search?q=%E3%81%84%E3%81%AC&tbm=isch
Monkey https://www.google.com/search?q=%E3%81%95%E3%82%8B&tbm=isch
Recommended Posts