有效期:2023-02-14
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"div.lmt__inner_textarea_container textarea"} (Session info: chrome=81.0.4044.138) Stacktrace: Backtrace: Ordinal0 [0x01385E93+2449043] Ordinal0 [0x012B8281+1606273] Ordinal0 [0x011AF889+522377] Ordinal0 [0x01148D18+101656] Ordinal0 [0x011648B0+215216] Ordinal0 [0x01159FE0+172000] Ordinal0 [0x0116326C+209516] Ordinal0 [0x01159E5B+171611] Ordinal0 [0x01141DD8+73176] Ordinal0 [0x01142E50+77392] Ordinal0 [0x01142DE9+77289] Ordinal0 [0x012CD7F7+1693687] GetHandleVerifier [0x01424576+522742] GetHandleVerifier [0x014242B4+522036] GetHandleVerifier [0x01439587+608775] GetHandleVerifier [0x01424DE6+524902] Ordinal0 [0x012C5BDC+1661916] Ordinal0 [0x012CF15B+1700187] Ordinal0 [0x012CF2C3+1700547] Ordinal0 [0x012E5135+1790261] BaseThreadInitThunk [0x75196A14+36] RtlInitializeExceptionChain [0x7730A9EF+143] RtlInitializeExceptionChain [0x7730A9BA+90]
__call__
def __call__(self, environ: dict, start_response: t.Callable) -> t.Any:
"""The WSGI server calls the Flask application object as the
WSGI application. This calls :meth:`wsgi_app`, which can be
wrapped to apply middleware.
"""
return self.wsgi_app(environ, start_response)
wsgi_app
try:
ctx.push()
response = self.full_dispatch_request()
except Exception as e:
error = e
response = self.handle_exception(e)
except: # noqa: B001
error = sys.exc_info()[1]
raise
return response(environ, start_response)
finally:
wsgi_app
ctx = self.request_context(environ)
error: t.Optional[BaseException] = None
try:
try:
ctx.push()
response = self.full_dispatch_request()
except Exception as e:
error = e
response = self.handle_exception(e)
except: # noqa: B001
error = sys.exc_info()[1]
full_dispatch_request
request_started.send(self)
rv = self.preprocess_request()
if rv is None:
rv = self.dispatch_request()
except Exception as e:
rv = self.handle_user_exception(e)
return self.finalize_request(rv)
def finalize_request(
self,
rv: t.Union[ResponseReturnValue, HTTPException],
full_dispatch_request
self.try_trigger_before_first_request_functions()
try:
request_started.send(self)
rv = self.preprocess_request()
if rv is None:
rv = self.dispatch_request()
except Exception as e:
rv = self.handle_user_exception(e)
return self.finalize_request(rv)
def finalize_request(
dispatch_request
getattr(rule, "provide_automatic_options", False)
and req.method == "OPTIONS"
):
return self.make_default_options_response()
# otherwise dispatch to the handler for that endpoint
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
def full_dispatch_request(self) -> Response:
"""Dispatches the request and on top of that performs request
pre and postprocessing as well as HTTP exception catching and
error handling.
deeplfy
if not to:
to="zh"
print(txt)
if not txt:
return
translated = deep_tranlate(txt,fr,to)
return translated
@app.route('/baidufy',methods=['GET','POST'])
def baidufy():
deep_tranlate
driver.get(deepl_url)
driver.implicitly_wait(2)
# Get thie inupt_area
input_css = 'div.lmt__inner_textarea_container textarea'
input_area = driver.find_element_by_css_selector(input_css)
# Send the text
input_area.clear()
input_area.send_keys(text_to_translate)
find_element_by_css_selector
warnings.warn(
"find_element_by_css_selector is deprecated. Please use find_element(by=By.CSS_SELECTOR, value=css_selector) instead",
DeprecationWarning,
stacklevel=2,
)
return self.find_element(by=By.CSS_SELECTOR, value=css_selector)
def find_elements_by_css_selector(self, css_selector) -> List[WebElement]:
"""
Finds elements by css selector.
find_element
value = ".%s" % value
elif by == By.NAME:
by = By.CSS_SELECTOR
value = '[name="%s"]' % value
return self.execute(Command.FIND_ELEMENT, {
'using': by,
'value': value})['value']
def find_elements(self, by=By.ID, value=None) -> List[WebElement]:
"""
execute
params['sessionId'] = self.session_id
params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
self.error_handler.check_response(response)
response['value'] = self._unwrap_value(
response.get('value', None))
return response
# If the server doesn't send a response, assume the command was
# a success
check_response
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here
raise exception_class(message, screen, stacktrace)
def _value_or_default(self, obj: Mapping[_KT, _VT], key: _KT, default: _VT) -> _VT:
return obj[key] if key in obj else default
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"div.lmt__inner_textarea_container textarea"} (Session info: chrome=81.0.4044.138) Stacktrace: Backtrace: Ordinal0 [0x01385E93+2449043] Ordinal0 [0x012B8281+1606273] Ordinal0 [0x011AF889+522377] Ordinal0 [0x01148D18+101656] Ordinal0 [0x011648B0+215216] Ordinal0 [0x01159FE0+172000] Ordinal0 [0x0116326C+209516] Ordinal0 [0x01159E5B+171611] Ordinal0 [0x01141DD8+73176] Ordinal0 [0x01142E50+77392] Ordinal0 [0x01142DE9+77289] Ordinal0 [0x012CD7F7+1693687] GetHandleVerifier [0x01424576+522742] GetHandleVerifier [0x014242B4+522036] GetHandleVerifier [0x01439587+608775] GetHandleVerifier [0x01424DE6+524902] Ordinal0 [0x012C5BDC+1661916] Ordinal0 [0x012CF15B+1700187] Ordinal0 [0x012CF2C3+1700547] Ordinal0 [0x012E5135+1790261] BaseThreadInitThunk [0x75196A14+36] RtlInitializeExceptionChain [0x7730A9EF+143] RtlInitializeExceptionChain [0x7730A9BA+90]
This is the Copy/Paste friendly version of the traceback.
The console is locked and needs to be unlocked by entering the PIN. You can find the PIN printed out on the standard output of your shell that runs the server.