Message element is not interactable

Question:

from selenium import webdriver  
import time
from selenium.webdriver.common.keys import Keys  
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import random
import select

driver = webdriver.Chrome('ChromeDriver')
driver.get("https://devbusiness.tunai.io/login")
time.sleep(2)
driver.maximize_window()

#log in credentials
username = driver.find_element(By.NAME, "loginUsername");
username.send_keys("xxxxx");

password = driver.find_element(By.NAME, "loginPassword");
password.send_keys("xxxxx");

login = driver.find_element(By.XPATH,"//*[@id='app']/div/div/div/div/div/div[2]/form/div[4]/button");
login.submit();
time.sleep(3)

driver.get("https://devbusiness.tunai.io/dashboard/my_salon_user")
time.sleep(3)

randomUsername = random.choice(["dayon.salon3@tunai","dayonmanager@tunai","Dayon.der@tunai"])
driver.find_element(By.XPATH, "//tbody[@role='rowgroup']/tr[@role='row']/td/a[text()='"+ randomUsername +"']").click()
print("Username selected: ", randomUsername)
time.sleep(5)

driver.find_element(By.XPATH,"//*[@id='page-content']/div/div[3]/div/div[2]/div/div/div[2]/div/div[1]/header/a").click()
time.sleep(5)

# Get the list of elements
elements = driver.find_elements(By.CLASS_NAME,'custom-control-input')

# Select a random element from the list
random_element = random.choice(elements)
driver.execute_script("arguments[0].click();", random_element)

# Click on the selected element
random_element.click()
print("Element selected: ", random_element)
time.sleep(5)

driver.find_element(By.XPATH,"//*[@id='accKey']").click()
time.sleep(5)

I’ve been add "argument.click[]","webdriver wait until EC to be clickable" but still showing "Element not interactable. What would be the other possible solution? Hope someone could clarify for me. Thanks and have a nice day.

Asked By: Carl Carl

||

Answers:

The problem is that you have picked an option randomly from the list but haven’t used it correctly. The usage random.choice(element) is incorrect.

You can use the below code as a reference for the problem that you are facing. Here //tbody[@role='rowgroup']/tr[@role='row']/td[2]/a is thy xpath for the table cell that contains all username fields (plus some other elements)

randomUsername = random.choice(["dayon@tunai","dayon.salon3@tunai","dayonmanager@tunai"])
driver.find_element(By.XPATH, "//tbody[@role='rowgroup']/tr[@role='row']/td/a[text()='"+randonUsername+"']").click()

in this first ine, this will first create a variable with a random value from your list.
Then it will pass the variable with the randomized option in the xpath for the table cell and click it. A new dialog with "Blocked Permissions" will open

Answered By: Manish

To click on specific username listed on table you need to use unique xpath to click.

After login added this code.

driver.get("https://devbusiness.tunai.io/dashboard/my_salon_user")
time.sleep(3)
randomtext = random.choice(["dayon@tunai","dayon.salon3@tunai","dayonmanager@tunai"])
element = driver.find_element(By.XPATH,"//table[@id='__BVID__74']/tbody//tr//td[2]//a[text()='{}']".format(randomtext))
element.click()
Answered By: KunduK