We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b8a5e37 commit 1999f10Copy full SHA for 1999f10
1 file changed
test-headless-browser.py
@@ -0,0 +1,30 @@
1
+from selenium.webdriver import Chrome
2
+from selenium.webdriver.chrome.options import Options
3
+
4
+from selenium.common.exceptions import NoSuchElementException
5
6
+# try:
7
+# pass
8
+# except NoSuchElementException as e:
9
+# print(e)
10
11
+# Creating a headless browser:
12
+opts = Options()
13
+opts.set_headless()
14
+assert opts.headless # Operating in headless mode
15
+browser = Chrome(options=opts)
16
+browser.get('https://duckduckgo.com')
17
18
19
+# Querying the DOM
20
+search_form = browser.find_element_by_id('search_form_input_homepage')
21
+search_form.send_keys('real python')
22
+search_form.submit()
23
24
25
+# Printing the results:
26
+results = browser.find_elements_by_class_name('result')
27
+print(results[0].text)
28
29
+browser.close()
30
+quit()
0 commit comments