Some drivers.find_element(By.LINK_TEXT, "XXXX") do not fail

Asked 2 years ago, Updated 2 years ago, 69 views

You can press では in the code below without any errors, but だ will print の error.
Please tell me the cause.It may not matter, but I also pasted the result of the pip list under the code.
① driver.find_element(By.LINK_TEXT, "Login")
② driver.find_element(By.LINK_TEXT, "FX Deal Start")
③ Message: no such element: Unable to locate element: {"method": "link text", "selector": "FX transaction start"}
(Session info: chrome=103.0.5060.114)

↓Python code

from here
import time
import chromedriver_binary
from selenium import webdriver
from selenium.webdriver.common.by import By
from concurrent.future import ThreadPoolExecutor
from concurrent.futures import ProcessPoolExecutor
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# Automatically install drivers
driver=webdriver.Chrome(service=Service(ChromeDriverManager().install())) 

# Set maximum load time Allow up to 30 seconds to wait this time
wait=WebDriverWait(driver=driver, timeout=30)

defaultSBI():
    try:
        # Open URL
        url="https://www.sbifxt.co.jp/login.html"
        # open utl
        driver.get(url)
        # wait for all the elements to be detected
        wait.until(EC.presence_of_all_elements_located)
        # // <input type="text" name="ID" id="loginid" class="fz12">
        name = driver.find_element(By.ID, "loginid")
        name.send_keys("1234567890")
        # // <input type="password" name="PASS" id="password" class="fz12">
        name = driver.find_element(By.ID, "password")
        name.send_keys("Password 1234")
        # <a href="javascript:postLoginUrl(MPAGE_URL);"onclick="$(this).click(function(e){return false});">Login</a>
        button=driver.find_element(By.LINK_TEXT, "Login")
        button.click()
        # wait for all the elements to be detected
        wait.until(EC.presence_of_all_elements_located)
        # <span class="c-lbl-sup">FX deal start</span>
        # // * [@id="home_depositGraph"]/section[1]/div/div/ul/li[1]/p/button[1]/span
        button1=driver.find_element(By.LINK_TEXT, "FX transaction start")
        button1.click()
        time.sleep(40)
    # If an error occurs, an error message is ejected.
    except Exception as:
        print(e)
        print("An error has occurred.")
    # exit the driver at the time
    finally:
        # Close Chrome
        driver.close()
        driver.quit()

if__name__=='__main__':
    with ThreadPoolExecutor(max_workers=8) as executor:
        executor.submit(openSBI)

↓Pip list

from here
Package Version
------------------- ---------------
async-generator 1.10
attrs21.4.0
certifi2022.6.15
cffi 1.15.1
charset-normalizer 2.1.0
chromedriver-binary 103.0.5060.53.0
cryptography 37.0.4
h110.13.0
idna 3.3
outcome 1.2.0
pip 22.1.2
picparser 2.21
pyOpenSSL 22.0.0
PySocks 1.7.1
python-dotenv 0.20.0
requests 2.28.1
selenium 4.3.0
setuptools 58.1.0
sniffio 1.2.0
sortedcontainers 2.4.0
trio 0.21.0
trio-websocket 0.9.2
urllib31.26.10
webdriver-manager 3.8.1
wsproto 1.1.0

python selenium chromedriver

2022-09-30 17:10

1 Answers

You receive an error stating that there is no element with the link text "Start FX Transaction".

「Message: no success element is an error to the effect that there is no matching element.

LINK_TEXT means exact match, so look for partial match in PATIAL_LINK_TEXT, or "FX" is wrong half-width and full-width.I think it can be solved by reviewing that area.


2022-09-30 17:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.