-
Hello! I'm new to Selenium testing. Below is the code I wrote for the test. def test_copy_as_csv_action(self):
self.goto(self.get_server_url())
self.reload()
checkbox = self.find_elements('input[type="checkbox"]')[0]
checkbox.click()
self.click('#actions .dropdown button')
self.click('#copy-as-csv')
self.assert_element('.success-popup')
clipboard_content = self.execute_async_script(
'let c = await navigator.clipboard.readText(); arguments[0](c)')
print(clipboard_content)
self.wait(5) Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @tobihans, --chromium-arg="ARG=N,ARG2" # (Set Chromium args, ","-separated, no spaces.) If you're just trying to copy/paste some text, you might not even need to use the clipboard. You can grab the text of an area by using: When running on a headless Linux display, you can add |
Beta Was this translation helpful? Give feedback.
Hi @tobihans,
For setting custom Chromium options, you can add the following to your
pytest
run command:If you're just trying to copy/paste some text, you might not even need to use the clipboard. You can grab the text of an area by using:
self.get_text(selector)
. Then, there are several ways of pasting the text in. For a pure paste, you can doself.add_text(selector, text)
/self.send_keys(selector, text)
, or if replacing existing text, useself.type(selector, text)
, which clears the text field before putting in the text.When running on a headless Linux display, you can add
--xvfb
topytest
so that you use a …