Last active
August 29, 2015 14:17
-
-
Save Xatpy/4ecc57203c4bdea04e2e to your computer and use it in GitHub Desktop.
Selenium Login CartoDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
from selenium.webdriver.common.action_chains import ActionChains | |
from time import gmtime, strftime | |
#driver = webdriver.Chrome() | |
driver = webdriver.Firefox() | |
driver.delete_all_cookies() | |
#driver.maximize_window() | |
driver.get('https://xatpy.cartodb.com/login') | |
email = driver.find_element_by_id("email") | |
password = driver.find_element_by_id("password") | |
password.send_keys("THE_PASSWORD") | |
password.send_keys(Keys.RETURN) | |
elem = driver.find_element_by_xpath('//*[@id="content-controller"]/div[2]/div/div/div[1]/div[2]/a') | |
elem.click() | |
newmap = driver.find_element_by_xpath('/html/body/div[6]/div/div/div[2]/div[2]/div[1]/button') | |
newmap.click() | |
driver.find_element_by_xpath('/html/body/div[6]/div/div/div[2]/div[4]/div[1]/div/div/div/div/ul/li[3]/button').click() | |
driver.find_element_by_xpath('/html/body/div[6]/div/div/div[2]/div[4]/div[2]/div[2]/div[2]/ul/li[5]/a').click() | |
driver.find_element_by_xpath('/html/body/div[6]/div/div/div[2]/div[4]/div[2]/div[2]/div[3]/div[5]/div[2]/div/button').click() | |
#finish table creation | |
driver.implicitly_wait(800) | |
#Create a row | |
driver.find_element_by_xpath('/html/body/div[3]/section[2]/div[2]/nav[2]/a[2]').click() | |
driver.find_element_by_xpath('/html/body/header/div/div[1]/div[2]/ul/li[3]/h1/a').click() | |
driver.implicitly_wait(10) | |
#Renaming table | |
name_table = driver.find_element_by_xpath("/html/body/div[8]/div/input") | |
name_table.clear() | |
hour_table_name = strftime("%Y_%m_%d_%H_%M_%S", gmtime()) | |
name_table.send_keys(hour_table_name) | |
name_table.send_keys(Keys.RETURN) | |
driver.find_element_by_link_text('Yes, do it').click() | |
#Change privacity | |
driver.find_element_by_class_name('privacy-status').click() | |
#Model privacity | |
driver.find_element_by_class_name(' privacy-link ').click() | |
#Select public | |
driver.find_element_by_xpath('/html/body/div[8]/div/section[1]/div[2]/div[1]/div/ul/li[1]/a').click() | |
#Clicking on "Save settings" | |
driver.implicitly_wait(500) | |
driver.find_element_by_xpath('/html/body/div[8]/div/section[1]/div[3]/a').click() | |
#Open new tab | |
ActionChains(driver).send_keys(Keys.COMMAND, "t").perform() | |
#driver.manage().deleteAllCookies() | |
driver.delete_all_cookies() | |
driver.implicitly_wait(500) | |
#Navigating in the new tab | |
driver.get('http://xatpy.cartodb.com/datasets') | |
#Check that the table exists | |
#driver.find_element_by_link_text(hour_table_name) | |
hour_table_name = 'table_' + hour_table_name | |
print ('table name: ' + hour_table_name) | |
driver.save_screenshot(hour_table_name + '.png') | |
print('bye') | |
#driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment