user13941200
user13941200

Reputation: 3

Message: no such element: Unable to locate element

i am not programmer but i like things with automation and still learning about it. Please advise me.

Here is my problem: I used Python Selenium to login this website anywhereconference.com and tried to login with moderator mode but those element was not found. The problem is, the login container is hidden under moderator container and need to click first.

Code

ntt = webdriver.Chrome()

ntt.get("https://anywhereconference.com")

ntt.set_window_size(1500, 800)

ntt.implicitly_wait(10)

mode = ntt.find_element_by_xpath('//*[@id="arka-login-moderator-type-button-header"]').click()

login = ntt.find_element_by_xpath('//*[@id="arka-login-moderator-weblogin"]')

login.send_keys('XXX')

login.send_keys(Keys.ENTER)

Error

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="arka-login-moderator-type-button-header"]"}
  (Session info: chrome=84.0.4147.89)

Click element

div id="arka-login-moderator" class="arka-login-button arka-login-moderator-button ui-button ui-widget ui-state-default ui-button-text-only ui-corner-left ui-corner-right arka-login-moderator-selected ui-state-active ready">

    <span class="ui-button-text">
        div id="arka-login-moderator-type-button-header" class="arka-login-type-button-header">I'm a moderator / admin</div
        div id="arka-login-moderator-type-button-text" class="arka-login-type-button-text">Start or schedule a meeting</div
    </span>

Login Page Example

i also try to used another method but still same but using Selenium IDE extension no problem.

Example 1

WebDriverWait(ntt, 20).until(
    EC.element_to_be_clickable((
        By.XPATH, '//*[@id='arka-login-moderator-type-button-header']")))
.click()

Example 2 JavaScript

mode = ntt.find_element_by_xpath(
    '//*[@id="arka-login-moderator-type-button-header"]')
    .click()
    ntt.execute_script("$(arguments[0]).click();", mode)

Upvotes: 0

Views: 627

Answers (2)

user2756757
user2756757

Reputation: 9

Change your xpath as follows

mode = ntt.find_element_by_xpath("//*[@id='arka-login-moderator-type-button-header']").click()

login = ntt.find_element_by_xpath("//*[@id='arka-login-moderator-weblogin']")

Upvotes: 0

SeleniumUser
SeleniumUser

Reputation: 4177

Try below code, iframe is present on your page you need to switch ifraame first before dealing with your web elements :

from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome(executable_path=r" path to chromedriver.exe")
driver.get("https://www.anywhereconference.com/")
driver.maximize_window()
iframe = WebDriverWait(driver, 20).until(
     EC.presence_of_element_located((By.NAME, 'globalFrameCenter')))
driver.switch_to.frame(iframe)

wait = WebDriverWait(driver, 30)

element = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='arka-login-moderator']//span"))).click()
actionChains = ActionChains(driver)
element = wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='arka-login-moderator-weblogin']"))).send_keys("Test")
wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='arka-login-moderator-pin']"))).send_keys("Test")

Output:

enter image description here

Upvotes: 1

Related Questions