Skip to content

Instantly share code, notes, and snippets.

@m0pfin
Last active December 3, 2021 22:23
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 m0pfin/0039d42a678560cbef65536ec5166cbc to your computer and use it in GitHub Desktop.
Save m0pfin/0039d42a678560cbef65536ec5166cbc to your computer and use it in GitHub Desktop.
Automated send ticket
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox import options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import requests
import unittest, time, re
import random
import string
profile = open('ticket.txt', 'r')
lines = profile.readlines()
profile_id = lines[0].strip()
print('ID profile: %s' % (profile_id))
#TODO replace with existing profile ID. Define the ID of the browser profile, where the code will be executed.
mla_profile_id = str(profile_id)
mla_url = 'http://127.0.0.1:35000/api/v1/profile/start?automation=true&profileId='+mla_profile_id
"""
Send GET request to start the browser profile by profileId. Returns response in the following format: '{"status":"OK","value":"http://127.0.0.1:XXXXX"}', where XXXXX is the localhost port on which browser profile is launched. Please make sure that you have Multilogin listening port set to 35000. Otherwise please change the port value in the url string
"""
resp = requests.get(mla_url)
json = resp.json()
#Define DesiredCapabilities
opts = options.DesiredCapabilities()
#Instantiate the Remote Web Driver to connect to the browser profile launched by previous GET request
driver = webdriver.Remote(command_executor=json['value'], desired_capabilities={})
#Perform automation
time.sleep(5)
driver.get('https://support.google.com/google-ads/contact/pf_suspended?ctx=123')
time.sleep(5)
#assert "Multilogin - Replace Multiple Computers With Virtual Browser Profiles - Multilogin" in driver.title
ad_account = driver.find_element(By.XPATH, '//*[@id="awcid_select"]/sc-shared-cid-selector/div/hcfe-search-select-select/div').click
ad_account_select = driver.find_element(By.XPATH, '//*[@id="awcid_select"]/sc-shared-cid-selector/div/hcfe-search-select-select/hcfe-search-select-menu/sc-shared-material-popup/div/div').click
phone = driver.find_element(By.XPATH, '//*[@id="pf_suspended"]/div[8]/input')
website = driver.find_element(By.XPATH, '//*[@id="website_req"]')
keywords = driver.find_element(By.XPATH, '//*[@id="sample_keywords"]')
street_adress = driver.find_element(By.XPATH, '//*[@id="billing_address_street"]')
zippcode = driver.find_element(By.XPATH, '//*[@id="billing_address_zip"]')
city = driver.find_element(By.XPATH, '//*[@id="billing_address_town"]')
who_pays = driver.find_element(By.XPATH, '//*[@id="who_pays"]')
desc_business = driver.find_element(By.XPATH, '//*[@id="business_desc"]')
summary_of_issue = driver.find_element(By.XPATH, '//*[@id="summary_of_issue"]')
#Click the link which opens in a new window
driver.execute_script("document.getElementById(':487').click()")
# Returns true if element is checked else returns false
checkbox = driver.find_element(By.XPATH, '//*[@id="pf_suspended"]/div[19]/fieldset/div[1]/div/label/span').click()
checkbox2 = driver.find_element(By.XPATH, '//*[@id="pf_suspended"]/div[20]/fieldset/div[1]/div/label/span').click()
#Click the link which opens in a new window
driver.execute_script("document.getElementById(':503').click()")
#Click the link which opens in a new window
driver.execute_script("document.getElementById(':569').click()")
#Enter login and pass
delay = 100
website.send_keys('https://edelweissrest.com') # GG First name
delay = 100
phone.send_keys('8478203829') # GG First name
delay = 400
keywords.send_keys('restuarant') # GG Last name
delay = 200
street_adress.send_keys('610 E Willamette Ave, Colorado Springs') # GG login name
delay = 400
zippcode.send_keys("80903")
delay = 300
city.send_keys("Colorado Springs")
delay = 300
desc_business.send_keys("I have a restaurant business")
delay = 300
who_pays.send_keys("I am")
delay = 300
summary_of_issue.send_keys("Hello unlock my account plz")
print ("Аппеляция подана!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment