Skip to content

Instantly share code, notes, and snippets.

@bbchriscesar
Created November 22, 2018 23:52
Show Gist options
  • Save bbchriscesar/7ea9cbed738048d96b185c6255588748 to your computer and use it in GitHub Desktop.
Save bbchriscesar/7ea9cbed738048d96b185c6255588748 to your computer and use it in GitHub Desktop.
from selenium import webdriver
import time
import os.path
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome(executable_path="chromedriver")
driver.maximize_window()
#Locales
locales = ['af', 'am', 'ar', 'bg', 'bn', 'ca', 'cs', 'da', 'de', 'el', 'en-GB', 'es', 'es-419', 'et', 'eu', 'fa', 'fi', 'fil', 'fr', 'fr-CA', 'gl', 'gu', 'hi', 'hr', 'hu', 'id', 'is', 'it', 'iw', 'ja', 'kn', 'ko', 'lt', 'lv', 'ml', 'mr', 'ms', 'nl', 'no', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv', 'sw', 'ta', 'te', 'th', 'tr', 'uk', 'ur', 'vi', 'zh-CN', 'zh-HK', 'zh-TW', 'zu']
driver.get('https://business.google.com/edit/l/02189009218636574205?hl=en')
time.sleep(2)
emailorphone = driver.find_element_by_xpath("//*[@id='identifierId']")
emailorphone.send_keys('lqa.oneweb111@gmail.com')
time.sleep(1)
driver.find_element_by_xpath("//*[@id='identifierNext']").click()
time.sleep(2)
yourpassword = driver.find_element_by_xpath("//input[@type='password']")
yourpassword.send_keys('youshallnotpass')
time.sleep(1)
driver.find_element_by_xpath("//*[@id='passwordNext']").click()
time.sleep(4)
for locale in locales:
path = '/usr/local/google/home/christiannec/GMB/' + locale
if not os.path.exists(path):
os.makedirs(path)
driver.get('https://business.google.com/edit/l/02189009218636574205?hl=' + locale)
time.sleep(8)
#Move to the bottom
webdriver.ActionChains(driver).send_keys(Keys.END).perform()
time.sleep(2)
driver.get_screenshot_as_file(path + '/' + '028_Merchant_Description.png')
time.sleep(1)
#Edit Add business
driver.find_element_by_xpath("//content//div[11]").click()
time.sleep(2)
driver.get_screenshot_as_file(path + '/' + '029_Merchant_Description.png')
time.sleep(1)
#Back
driver.back()
time.sleep(1)
#Opening date
driver.find_element_by_xpath("//content//div[12]").click()
time.sleep(2)
driver.get_screenshot_as_file(path + '/' + '030_Opening_date.png')
time.sleep(1)
#Month drop down
driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[4]/div[1]/span[2]/span/div/div[1]/div[2]").click()
time.sleep(2)
driver.get_screenshot_as_file(path + '/' + '031_Opening_date.png')
time.sleep(1)
#Press ESCAPE
webdriver.ActionChains(driver).send_keys(Keys.ESCAPE).perform()
time.sleep(2)
#Day drop down
driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[4]/div[1]/span[3]/div/div[1]/div[2]").click()
time.sleep(2)
driver.get_screenshot_as_file(path + '/' + '032_Opening_date.png')
time.sleep(1)
#Press ESCAPE
webdriver.ActionChains(driver).send_keys(Keys.ESCAPE).perform()
time.sleep(2)
#Clear year box
driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[4]/div[1]/span[1]/div/div[1]/div/div[1]/input").clear()
time.sleep(1)
yearinput = driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[4]/div[1]/span[1]/div/div[1]/div/div[1]/input")
yearinput.send_keys('fvcx')
time.sleep(1)
#Apply
driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[5]/div[2]/content/span").click()
time.sleep(2)
driver.get_screenshot_as_file(path + '/' + '033_Opening_date.png')
time.sleep(2)
#Enter data (year, month & day)
driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[4]/div[1]/span[1]/div/div[1]/div/div[1]/input").clear()
time.sleep(1)
yearinput11 = driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[4]/div[1]/span[1]/div/div[1]/div/div[1]/input")
yearinput11.send_keys('2019')
time.sleep(1)
#Month
driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[4]/div[1]/span[2]/span/div/div[1]/div[2]").click()
time.sleep(1)
driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[4]/div[1]/span[2]/span/div/div[2]/div[14]/content").click()
time.sleep(1)
#Day
driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[4]/div[1]/span[3]/div/div[1]/div[2]").click()
time.sleep(1)
driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[4]/div[1]/span[3]/div/div[2]/div[22]/content").click()
time.sleep(2)
#Apply
driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[5]/div[2]/content/span").click()
time.sleep(4)
driver.get_screenshot_as_file(path + '/' + '034_Opening_date.png')
time.sleep(1)
#Input correct date for opening
driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[4]/div[1]/span[1]/div/div[1]/div/div[1]/input").clear()
time.sleep(1)
yearinput112 = driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[4]/div[1]/span[1]/div/div[1]/div/div[1]/input")
yearinput112.send_keys('2015')
time.sleep(2)
#Apply
driver.find_element_by_xpath("//*[@id='js']/div[12]/div/div[2]/content/div/div[5]/div[2]/content/span").click()
time.sleep(6)
driver.get_screenshot_as_file(path + '/' + '035_Opening_date.png')
time.sleep(1)
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment