2

Everyone,

I would like to browse the following website by using Selenium.

https://www.kintips.com/tc/kintips-app.html

(please select "ENG" if you can only read English.)

Here is what I wanted to do:

  1. Open the website with Edge.
  2. Click the "User Login" button.
  3. Enter ID and password.
  4. Click "Login".

I was stuck at Step 2. I tried many strategies like find_element_by_class_name and find_element_by_css_selector. But all the responses were "no such element: Unable to locate element".

How do I locate the element for "User Login" button? Please help. Thank you.

from selenium import webdriver

browser = webdriver.Edge()

#step 1
browser.get('https://kintips.com/tc/kintips-app.html')

#step 2, click a button
current = browser.find_elements_by_class_name('button-inner')

1 Answer 1

1

The login button is contained in a iframe webelement (to view it open the browser inspector tool and search //iframe) that's why it gives you the error "no such element: Unable to locate element". First you have to switch to the iframe, and then you can find the element, as shown in the code below

import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

browser = webdriver.Edge()

browser.get('https://kintips.com/tc/kintips-app.html')

# pause 30 seconds to let the page load fully, you can reduce or increase this value to your needs
time.sleep(30)

WebDriverWait(browser, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, "iframe[src*='iads001']")))
login_button = browser.find_element(By.CSS_SELECTOR, "button[class*='login']")
login_button.click()
Sign up to request clarification or add additional context in comments.

1 Comment

You codes solve the problem and help me with the rest of the steps. Thank you.

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.