-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathexample.py
More file actions
40 lines (29 loc) · 877 Bytes
/
example.py
File metadata and controls
40 lines (29 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from chromeless import Chromeless
import os
demo_url, supposed_title = "https://example.com/", "example domain"
def example(self, url):
self.url = url
title = self.second_method()
png = self.get_screenshot_as_png()
divcnt = len(self.find_elements_by_xpath("//div"))
return title, png, divcnt
def second_method(self):
self.get(self.url)
return self.title
def test_example():
chrome = Chromeless()
chrome.attach(example)
chrome.attach(second_method)
result = chrome.example(demo_url)
print(result)
return result
def test_api():
chrome = Chromeless(os.getenv('API_URL', "None"),
os.getenv('API_KEY', "None"))
chrome.attach(example)
chrome.attach(second_method)
result = chrome.example(demo_url)
print(result)
return result
if __name__ == '__main__':
test_example()