Home>

I'm thinking of creating a tool that automatically obtains information from JplatPat of the Patent Office using Python and Selenium.
I'm making a tool by automatically creating Python code using SeleniumIDE.

In Jplatpat, set the publication number to "2011-161271", click and click
The link of "Japanese Patent Laid-Open No. 2011-161271" was successfully displayed.

So I want to click that link to bring up another window,
I can't do that.

The error message is below.

runfile ('C: /Users/ksclu/.spyder-py3/test.py', wdir ='C: /Users/ksclu/.spyder-py3')
Traceback (most recent call last):

File "C: \ Users \ ksclu \ .spyder-py3 \ test.py", line 32, in
element = driver.find_element_by_link_text ("Japanese Patent Laid-Open No. 2011-161271")

File "C: \ Users \ ksclu \ anchorda3 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py", line 428, in find_element_by_link_text
return self.find_element (by = By.LINK_TEXT, value = link_text)

File "C: \ Users \ ksclu \ anaconda3 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py", line 978, in find_element
'value': value}) ['value']

File "C: \ Users \ ksclu \ anaconda3 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py", line 321, in execute
self.error_handler.check_response (response)

File "C: \ Users \ ksclu \ anaconda3 \ lib \ site-packages \ selenium \ webdriver \ remote \ errorhandler.py", line 242, in check_response
raise exception_class (message, screen, stacktrace)

NoSuchElementException: no such element: Unable to locate element: {"method": "link text", "selector": "Japanese Patent Laid-Open No. 2011-161271"}
(Session info: chrome = 87.0.4280.66)

Corresponding source code

The language is Python.
The source code is below.

import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

import chromedriver_binary # code to pass

driver = webdriver.Chrome () #Prepare Chrome
vars = {}

driver.set_window_size (923, 1072)
driver.find_element (By.ID, "p00_srchCondtn_txtDocNoInputNo1"). click ()
driver.find_element (By.ID, "p00_srchCondtn_txtDocNoInputNo1"). send_keys ("2011-161271")
driver.find_element (By.CSS_SELECTOR, "# p00_searchBtn_btnDocInquiry>span"). click ()
element = driver.find_element_by_link_text ("Japanese Patent Laid-Open No. 2011-161271")
element.click ()

What I tried

It seems that the usage of driver.find_element_by_link_text is not good.
I've tried using Xpath, but it doesn't work.

Supplementary information (FW/tool version, etc.)

Nothing in particular.

Please write your question in detail here.
(Example) I am making a ●● system with PHP (CakePHP).
■■ The following error message occurred while implementing the function.

Error message
Corresponding source code
Source code
What I tried

Please describe here what you have tried for the problem.

Supplementary information (FW/tool version, etc.)

Please provide more detailed information here.

  • Answer # 1

    driver.find_element_by_link_text ("Japanese Patent Laid-Open No. 2011-161271")

    IsJP 2011-161271likeaIt means to select a tag, but is it correct?
    Are there spaces before and after the text?

    Postscript

    time.sleep (1)Let's put in.
    If the program runs on the server side and returns the page instead of following a simple link, it's better to wait a moment.

Trends