1

So, I've decided to make TikTok massfollower, but can't go further than login.

from selenium.webdriver import Firefox
from time import sleep

browser = Firefox()

browser.get('https://www.tiktok.com/foryou?lang=ru')
login = browser.find_element_by_class_name('jsx-3665539393')
login.click()

sleep(10)

login2 = browser.find_element_by_class_name('channel-name-2Dwny')
login2.click()

It goes to TikTok website, then it presses the log-in button, and then there is pop-up window(I hope that's the right way to call it). But program can't find elements on this pop-up window, I thought that I should wait for pop-up to load, but there is no difference.

1 Answer 1

1

The element you are after is inside an iframe you need to switch to iframe first in order to access the element.

Induce WebDriverWait() and wait for frame_to_be_available_and_switch_to_it() and following css selector.

Induce WebDriverWait() and wait for element_to_be_clickable()

browser.get('https://www.tiktok.com/foryou?lang=ru')
#Click on Login
WebDriverWait(browser,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"a.jsx-3665539393"))).click()
#Click cookeis button
WebDriverWait(browser,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"div.button-wrapper>button"))).click()

WebDriverWait(browser,10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[src*='tiktok']")))
browser.execute_script("arguments[0].click();",WebDriverWait(browser,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"div.close-modal-8dfIo"))))

You need to import following libraries

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.