I am trying to access this website: Tradingview.com
I wrote a piece of Python code which uses selenium to do access it. After accessing the website, my goal is to click on the "Tweet Image" button. In order to do so, I need to first find the camera buttons' css path so that I can click on it. I cannot find the css path to the camera button.
This is my existing python code:
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
# some constants
DRIVER_PATH = 'path_to_chromedriver'
EMAIL = 'my_email_id'
PWD = 'my_password'
class Browser:
def __init__(self, driver: str, keep_open: bool) -> None:
self.service = Service(driver)
chrome_options = Options()
chrome_options.add_experimental_option("detach", keep_open)
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
self.driver = webdriver.Chrome(service=self.service, options=chrome_options)
def open_page(self, url: str):
self.driver.get(url)
self.driver.maximize_window()
def close(self):
time.sleep(5)
print("shutting down browser")
self.driver.close()
def sign_in(self):
# open the sign in page
self.open_page("https://www.tradingview.com/#signin")
# click the email button
button = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.NAME, "Email")))
button.click()
# enter email, password & click sign in
self.driver.find_element(By.ID, "id_username").send_keys(EMAIL)
self.driver.find_element(By.ID, "id_password").send_keys(PWD)
sign_in_btn = self.driver.find_element(By.CSS_SELECTOR, ".submitButton-LQwxK8Bm.button-D4RPB3ZC.size-large-D4RPB3ZC.color-brand-D4RPB3ZC.variant-primary-D4RPB3ZC.stretch-D4RPB3ZC")
sign_in_btn.click()
def click_products_tab(self):
products_tab = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, "Products")))
products_tab.click()
def click_tweet_image(self):
tweet_image = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, "Tweet Image")))
tweet_image.click()
def save_chart_img(self):
ActionChains(self.driver).key_down(Keys.ALT).send_keys('s').perform()
element = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, 'Save image')))
element.click()
browser = Browser(DRIVER_PATH, True)
# sign in
browser.sign_in()
# click on "Products" tab
browser.click_products_tab()
# click on "Tweet Image" button
# I'm stuck here
I need help finding the css path of that camera button. I have tried right-clicking and inspecting it but everytime I right click, I don't get an option to inspect it.