[Python] Sending commands to an opened link in Selenium with Python

Discussão em 'Python' iniciado por Stack, Dezembro 9, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to write a code that will go to a web page with links, search though each link by element, click on the link and then save it.

    So far I have managed to find the link that I want and click on it. I am trying to send the keys CTRL + S and ENTER, but I keep getting error.

    Error Details:

    File "c:\Users\Victor\Desktop\Selenium\main.py", line 19, in <module>
    open_link.send_keys(Keys.CONTROL + "s")
    ^^^^^^^^^^^^^^^^^^^
    AttributeError: 'NoneType' object has no attribute 'send_keys'


    Here's what I have so far:

    import selenium
    import time
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys



    driver = webdriver.Firefox()

    driver.get("https://www.examtopics.com/discussions/comptia/94/")

    driver.implicitly_wait(0.5)

    search = driver.find_element(By.PARTIAL_LINK_TEXT, "CAS-004")

    open_link= search.click()

    open_link.send_keys(Keys.CONTROL + "s")

    open_link.send_keys(Keys.ENTER)



    I feel like I'm almost there but I'm stuck at this point.

    Continue reading...

Compartilhe esta Página