[PYTHON] Read the URL list with Robot Framework and surround the screenshots

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

Read the URL list with Robot Framework and surround the screenshots
Read the linked list in csv format with graph-tool
[Python] Read the csv file and display the figure with matplotlib
Read the VTK file and display the color map with jupyter.
Robot running with Arduino and python
Run Pylint and read the results
Read the graph image with OpenCV and get the coordinates of the final point of the graph
Read the file with python and delete the line breaks [Notes on reading the file]
I measured the speed of list comprehension, for and while with python2.7.
Touch around the twitter list with tweepy
Let's read the RINEX file with Python ①
Read and write csv files with numpy
Touch AWS with Serverless Framework and Python
Read CSV and analyze with Pandas and Seaborn
Create a simple reception system with the Python serverless framework Chalice and Twilio