-1

I want to click the interface setup button in the top menu of the TP-Link modem settings (192.168.1.1)

HTML:

<td width="85" bgcolor="#FFFFFF"><a href="navigation-basic.html" onclick="javascript:top.main.location=
&quot;../basic/home_wan.htm&quot;">
<font color="#666666">Interface<br>Setup</font></a></td>

My code:

driver = webdriver.Chrome(service_log_path=devnull)
driver.get('http://192.168.1.1')
driver.find_element(By.NAME, 'Login_Name').send_keys('admin')
driver.find_element(By.NAME, 'Login_Pwd').send_keys('admin')
driver.find_element(By.NAME, 'texttpLoginBtn').click()

Error:

[8500:6912:0726/130142.901:ERROR:device_event_log_impl.cc(214)] [13:01:42.909] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[8500:6912:0726/130142.919:ERROR:device_event_log_impl.cc(214)] [13:01:42.918] Bluetooth: bluetooth_adapter_winrt.cc:1074 Getting Default Adapter failed.
Traceback (most recent call last):
  File "d:\NetBlocker\NetBlocker.py", line 33, in <module>
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[href^='navigation-basic'][onclick*='home_wan']"))).click()
  File "C:\--\--\--\--\--\Python310\site-packages\selenium\webdriver\support\wait.py", line 90, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
Backtrace:
        Ordinal0 [0x00665FD3+2187219]
        Ordinal0 [0x005FE6D1+1763025]
        Ordinal0 [0x00513E78+802424]
        Ordinal0 [0x00541C10+990224]
        Ordinal0 [0x00541EAB+990891]
        Ordinal0 [0x0056EC92+1174674]
        Ordinal0 [0x0055CBD4+1100756]
        Ordinal0 [0x0056CFC2+1167298]
        Ordinal0 [0x0055C9A6+1100198]
        Ordinal0 [0x00536F80+946048]
        Ordinal0 [0x00537E76+949878]
        GetHandleVerifier [0x009090C2+2721218]
        GetHandleVerifier [0x008FAAF0+2662384]
        GetHandleVerifier [0x006F137A+526458]
        GetHandleVerifier [0x006F0416+522518]
        Ordinal0 [0x00604EAB+1789611]
        Ordinal0 [0x006097A8+1808296]
        Ordinal0 [0x00609895+1808533]
        Ordinal0 [0x006126C1+1844929]
        BaseThreadInitThunk [0x760DFA29+25]
        RtlGetAppContainerNamedObjectPath [0x773A7A9E+286]
        RtlGetAppContainerNamedObjectPath [0x773A7A6E+238]

PS D:\NetBlocker> [8500:1368:0726/130237.390:ERROR:util.cc(127)] Can't create base directory: C:\Program Files\Google\GoogleUpdater
[7988:4812:0726/130337.193:ERROR:gpu_init.cc(486)] Passthrough is not supported, GL is disabled

I tried different methods but none of them worked.

Snapshot:

interface setup

1 Answers1

0

To click on the element with text Interface Setup you need 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[href^='navigation-basic'][onclick*='home_wan']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[starts-with(@href, 'navigation-basic')][contains(@onclick, 'home_wan')]"))).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
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352