Click through a table of hyperlinks My goal was to click every single hyperlink under the "Shortcuts" header on here.

The code looks like it works to me, but if you have ideas that could help me improve/change I would love to hear them! Please do not be to critical of my variable naming.

#   Author: Brandon Finley
#   Date: 5/17/2017
#   Purpose: Clicks on every link of the selenium2library shortcuts by counting how many
#            elements it has in the table.
*** Settings ***
Library     Selenium2Library
Suite Setup   Open Browser   http://robotframework.org/Selenium2Library/Selenium2Library.html   chrome

*** Variables ***
${SHORTCUTS} =  dom=document.getElementsByClassName("shortcuts")[0].childNodes

*** Test Cases ***
Testing
    #   First half of the shortcuts table has shortcuts-container xpath name
    ${Cuts-Container} =  get matching xpath count  //*[@id="shortcuts-container"]/div/a
    #   Second half of the shortcuts table has keywords-container xpath name
    ${Key-Container} =  get matching xpath count  //*[@id="keywords-container"]/table/tbody/tr
    #   Count is the addition of both xpath names integer
    ${COUNT} =  evaluate  ${Cuts-Container}+${Key-Container}

    #   Simple for loop that will only click on every odd element because every even
    #   element is a non-clickable symbol used to make the shortcuts table look pretty
    : FOR   ${INPUT}    IN RANGE    0   ${COUNT}
    \   ${ODD?} =    evaluate  ${INPUT}%2
    \   Only Click Odd  ${ODD?}   ${INPUT}
    \   sleep   .2s

*** Keywords ***
Only Click Odd
    [Arguments]  ${EvenOrOdd}    ${Counter}
    run keyword if  ${EvenOrOdd}==1  click element  ${SHORTCUTS}[${Counter}]
Given one of the main highlights of Robot Framework is readability, I'll show my suggestions to improve that first and then go into my mechanical suggestions.

First, good readability practice in Robot Framework is to line up your cells by tabs (or sets of four characters depending on your IDE) and capitalize each word of your keyword uses. So, your code as sent would look like this.

*** Settings ***
Library         Selenium2Library
Suite Setup     Open Browser    http://robotframework.org/Selenium2Library/Selenium2Library.html    chrome

*** Variables ***
${SHORTCUTS} =  dom=document.getElementsByClassName("shortcuts")[0].childNodes

*** Test Cases ***
Testing
    #   First half of the shortcuts table has shortcuts-container xpath name
    ${Cuts-Container} =     Get Matching Xpath Count    //*[@id="shortcuts-container"]/div/a
    #   Second half of the shortcuts table has keywords-container xpath name
    ${Key-Container} =      Get Matching Xpath Count    //*[@id="keywords-container"]/table/tbody/tr
    #   Count is the addition of both xpath names integer
    ${COUNT} =              Evaluate    ${Cuts-Container}+${Key-Container}

    #   Simple for loop that will only click on every odd element because every even
    #   Element is a non-clickable symbol used to make the shortcuts table look pretty
    : FOR   ${INPUT}    IN RANGE    0   ${COUNT}
    \   ${ODD?} =   Evaluate    ${INPUT}%2
    \   Only Click Odd  ${ODD?}     ${INPUT}
    \   Sleep   .2s

*** Keywords ***
Only Click Odd
    [Arguments]     ${EvenOrOdd}    ${Counter}
    Run Keyword If  ${EvenOrOdd}==1     Click Element   ${SHORTCUTS}[${Counter}]


I'm not trying to be too critical of your variable naming but I do have to be for completionism and for other future Robot Framework users looking for how to write readable code. Because (it appears) that you're using the Python version of Robot Framework, I'd say it's good practice to keep to the Python convention of naming variables, which is lower_case_with_underscores for local variables or UPPER_CASE_WITH_UNDERSCORES for global variables and index variables in loops. Also, shorter, more descriptive variable names are perfectly acceptable for this size of program. Re-written for that, your variables should be ${shortcuts}, ${keywords}, ${count}, ${odd}, ${even_or_odd}, and ${counter}.

Mechanically, I'm assuming it works fine as-written, but there's a few optimization problems. First, having a custom keyword for a single action is usually redundant (unless you want to simplify a repeated action with a lot of parameters to a single word for readability), so you could re-write your For loop as follows (using the re-formatted variables):

: FOR   ${INPUT}    IN RANGE    0   ${count}
    \   ${odd} =   Evaluate    ${INPUT}%2
    \   Run Keyword If  ${odd}==1     Click Element   ${SHORTCUTS}[${INPUT}]
    \   Sleep   .2s


That makes the keyword unnecessary, making your code easier to maintain.

Finally, as another good practice, Selenium2Library is outdated. You'll need to download it separately, but ExtendedSelenium2Library is more robust, contains more keywords, and includes code to deal with Angular applications.

The final code after formatting and optimization looks like this (I also took some liberties on comments that are either unnecessary or too wordy for what they describe):

*** Settings ***
Library         ExtendedSelenium2Library
Suite Setup     Open Browser    http://robotframework.org/Selenium2Library/Selenium2Library.html    chrome

*** Variables ***
${SHORTCUTS} =  dom=document.getElementsByClassName("shortcuts")[0].childNodes

*** Test Cases ***
Testing
    #   Count the number of shortcuts and keywords
    ${shortcuts} =  Get Matching Xpath Count    //*[@id="shortcuts-container"]/div/a
    ${keywords} =   Get Matching Xpath Count    //*[@id="keywords-container"]/table/tbody/tr
    ${count} =      Evaluate    ${shortcuts}+${keywords}

    #   Click every odd element (evens are unclickable)
    : FOR   ${INPUT}    IN RANGE    0   ${count}
        \   ${odd} =        Evaluate    ${INPUT}%2
        \   Run Keyword If  ${odd}==1   Click Element   ${SHORTCUTS}[${INPUT}]
        \   Sleep           .2s


In other notes, this is actually a very good first Robot Framework script that is very optimal (as far as I can tell) other than my suggestions.

Also, I completely missed who wrote this code originally when I was writing up this review. I know this guy IRL. Hey Fin! Hope this explained how I get my code to look so nice.