1

A beginner in JS/Html, I'm trying to click on a link in an unordered list, through Pyppeteer0.2.5 (Python3.6.9/Chromium 87.0.4280.66). The html code of the link is:

<li class="ml2 sel"><a class="click sel clicked" href="javascript:void(0);" url="qosSettings.htm"><span class="text T">Settings</span></a></li>

My pyppeteer code is:

await page.click('[class="click sel clicked"]')

But I get an error:

Traceback (most recent call last):
  File "test.py", line 77, in <module>
    asyncio.get_event_loop().run_until_complete(main())
  File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
    return future.result()
  File "test.py", line 55, in main
    await go_to_qos_settings(page)
  File "test.py", line 26, in go_to_qos_settings
    await page.click(btn)
  File "/home/me/.local/lib/python3.6/site-packages/pyppeteer/page.py", line 1546, in click
    await frame.click(selector, options, **kwargs)
  File "/home/me/.local/lib/python3.6/site-packages/pyppeteer/frame_manager.py", line 581, in click
    handle = await self.J(selector)
  File "/home/me/.local/lib/python3.6/site-packages/pyppeteer/frame_manager.py", line 317, in querySelector
    value = await document.querySelector(selector)
  File "/home/me/.local/lib/python3.6/site-packages/pyppeteer/element_handle.py", line 360, in querySelector
    self, selector,
  File "/home/me/.local/lib/python3.6/site-packages/pyppeteer/execution_context.py", line 113, in evaluateHandle
    helper.getExceptionMessage(exceptionDetails)))
pyppeteer.errors.ElementHandleError: Evaluation failed: DOMException: Failed to execute 'querySelector' on 'Document': 'javascript:void(0);' is not a valid selector.
    at __pyppeteer_evaluation_script__:1:33

Any idea how to click on a link whose href is javascript:void(0);? From what I've read this can sometimes be replaced by an onclick method but no such thing appears in the html code.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.