0

I want to make a simple attendance automation with python for my college, I make this for ease, because this took so many button to click but, I cannot click the tag <a> with tag <i> inside it.

<a href="http://siakad.polinema.ac.id/mahasiswa/tr_absensi/add" 
class="btn btn-sm green-meadow btn-add-data" id="btn-add-wizard">
<i class="fa fa-plus"></i> Absen</a>

I use this wait function, and still not directed into that link. It shows nothing on result. Process finished with exit code 0

wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,"//a[contains(@href, ""'http://siakad.polinema.ac.id/mahasiswa/tr_absensi/add')]"))).click()

I tried using ID and LINK_TEXT and still showing Process finished with exit code 0.

Thank you, apologize for my english. Enghlish is not my main language. If you need more information about my question, please let me know.

1 Answer 1

1

To click on the element with text as Absen you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a.btn.btn-sm.green-meadow.btn-add-data#btn-add-wizard[href$='id/mahasiswa/tr_absensi/add']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@class='btn btn-sm green-meadow btn-add-data' and @id='btn-add-wizard'][contains(@href, 'id/mahasiswa/tr_absensi/add')]"))).click()
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
Sign up to request clarification or add additional context in comments.

Comments

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.