0

I have a code that goes on instagram, connect to my account, enter passcode, and search a user. I want to see if aria-disabled is "true". I simply want to print if it's set to 'true'.

I just can't seem to make to make it work.

<div class="_aarf" aria-disabled="true" role="button" tabindex="-1">

The code :

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

#specify the path to chromedriver.exe (download and save on your computer)
driver = webdriver.Chrome('C:/Users/me/Desktop/IG_APP/chromedriver.exe')

#open the webpage
driver.get("http://www.instagram.com")

#target username
username = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='username']")))
password = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='password']")))

#enter username and password
username.clear()
username.send_keys("MYUSERID")
password.clear()
password.send_keys("MYPASSWORD")

#target the login button and click it
button = WebDriverWait(driver, 2).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button[type='submit']"))).click()

not_now = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//button[contains(text(), "Not Now")]'))).click()
not_now2 = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//button[contains(text(), "Not Now")]'))).click()

import time

# target the search input field
searchbox = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//input[@placeholder='Search']")))
searchbox.clear()

# search for the user
keyword = "@test"
searchbox.send_keys(keyword)


time.sleep(2)
searchbox.send_keys(Keys.ENTER)
time.sleep(2)
searchbox.send_keys(Keys.ENTER)
time.sleep(2)

When I found my user, All I want is to know, if the attribute aria-disabled is "true"

2
  • It would be much easier for us to help you with your question if you could share the code you tried using to accomplish this.
    – cvionis
    Oct 12, 2022 at 3:19
  • I tried several things but none worked. I edited my question to add my entire code
    – Pythoner
    Oct 12, 2022 at 3:30

1 Answer 1

0

You can use 'get_attribute()' function.

Ex:

value = driver.find_element(By.XPATH,"<put the correct xpath here>").get_attribute("aria-disabled")
0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.