2
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By

chrome_options = webdriver.ChromeOptions()
driver = webdriver.Chrome(r'chromedriver.exe', options=chrome_options)
url = 'https://rarible.com/connect'
b = 1

def main():
    driver.get(url)
    input('Login..(Press ENTER when finsihed)')
    sleep(1)
    while driver.current_url == "https://rarible.com/":
        ts_href = '/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div[4]/div[2]/div/div[1]/div[1]/div/div/div[' \
                  '1]/div[1]/div/div[3]/a'
        href = driver.find_element(By.XPATH, ts_href).get_attribute('href')
        driver.get(href)
        sleep(2)
        followers = '/html/body/div/div[2]/div[2]/div[2]/div[2]/div/div/div/div[1]/div[5]/div/button[1]/span[2]'
        driver.find_element(By.XPATH, followers).click()
        sleep(3)

        # buttons = driver.find_elements(By.XPATH, '//button[normalize-space()="Follow"]')
        def butts():
            global b
            fbtn = f'/html/body/div/div[1]/div/div[2]/div/div[2]/div/div/div/div[{b}]/div/div/div[3]/button'
            buttons = driver.find_element(By.XPATH, fbtn)
            print(f'BUTTON {b} TEXT (FOLLOW/UNFOLLOW): {buttons.text}')
            if buttons.text == "Follow":
                buttons.click()
                b += 1
                sleep(1)
                butts()
            elif buttons.text == "Unfollow":
                b += 1
                butts()

        butts()
        print('All set here, onto the next one...')
    else:
        driver.get('https://rarible.com/')


if __name__ == '__main__':
    main()

I cannot get it to click the follow buttons. I Can't find an iframe that they are hiding in, or any other type of javascript voodoo being done but i am not the most experienced. Which is why i come to you seeking guidance.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
  • look here: https://stackoverflow.com/questions/44834358/switch-to-an-iframe-through-selenium-and-python you first need to switch to iframe before trying to click anything inside it. – Jacek Ratajewski Oct 28 '21 at 09:00
  • JUst an update, still struggling here.. I have switched out to try firefox/geckodriver, i have tried full screen, lookings for overlays or any other obstructions, searched for iframes that i may need to enter.. nothing is working for me here. – Justplainpaulie Oct 29 '21 at 00:04

1 Answers1

0

The line where you define followers wasn't working for me so I changed it to followers = '//button[@datamarker="root/appPage/address/profile/followingLinks/followers"]'

Trying to figure out how to get the butts() loop to run, but I don't have any followers on rarible so it's kind of hard to test. However, putting these lines of code in at the end of "if buttons.text == "Follow": before butts() is called again might work. scroll_div = driver.find_element(By.XPATH, '/html/body/div/div[1]/div/div[2]/div/div[2]/div/div/div') scroll_div.send_keys(Keys.ARROW_DOWN)

It's not actually an iframe. The solution has something to do with scrolling through the follow buttons

Jeffrey Kozik
  • 201
  • 4
  • 8