Skip to content

Instantly share code, notes, and snippets.

@redgeoff
Last active March 2, 2022 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redgeoff/f5dd0c660e4ba987173104b6af8c33c6 to your computer and use it in GitHub Desktop.
Save redgeoff/f5dd0c660e4ba987173104b6af8c33c6 to your computer and use it in GitHub Desktop.
Grocery Shopping Bot: Get Todoist List
*** Variables ***
${TODOIST_TODAY} https://todoist.com/app/today
${TODOIST_TODAY_TITLE} Today: Todoist
*** Keywords ***
Log In To Todoist
[Arguments] ${email} ${password}
Wait Until Element Ready email
Wait Until Element Ready password
Input Text email ${email}
Input Password password ${password}
Click Button Log in
Wait Until Page Contains Today timeout=30s
Update Settings If Needed
Log In Or Open Todoist Inner
[Arguments] ${email} ${password}
Go To ${TODOIST_TODAY}
Wait Until Page Contains Element xpath=//*[.='Log in' or .='Today'] # Wait for page to settle
${logged_in}= Run Keyword And Return Status Title Should Be ${TODOIST_TODAY_TITLE}
IF not ${logged_in}
Log In To Todoist ${email} ${password}
END
Log In Or Open Todoist
[Arguments] ${email} ${password}
Wait Until Keyword Succeeds 5x 2 sec Log In Or Open Todoist Inner ${email} ${password}
Select Todoist List
[Arguments] ${list_name}
Update Settings If Needed
Click Element When Ready xpath:(.//span[contains(., '${list_name}')])[1]
Get Todoist List Items
@{locators}= Get WebElements xpath=//li[contains(@class,'task_list_item')]
${items}= Create List
FOR ${locator} IN @{locators}
${list_item} Get Child WebElements ${locator} //div[contains(@class,'task_list_item__content')]
${name}= Get Text ${list_item}
${id}= Get Element Attribute ${locator} data-item-id
${item}= Create Dictionary id=${id} name=${name}
Append To List ${items} ${item}
END
[Return] ${items}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment