-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathExamplePlugin.py
More file actions
28 lines (23 loc) · 1.08 KB
/
Copy pathExamplePlugin.py
File metadata and controls
28 lines (23 loc) · 1.08 KB
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
import json
from robot.api.deco import keyword # Decorator to mark which methods are keyword
from Browser.base.librarycomponent import (
LibraryComponent, # Plugin class must always inherit LibraryComponent
)
from Browser.generated.playwright_pb2 import (
Request, # GRPC stub which is used to talk Playwright running in node side
)
class ExamplePlugin(LibraryComponent): # Inherit LibraryComponent
@keyword # This method is keyword
def new_plugin_cookie_keyword(self) -> dict:
with self.playwright.grpc_channel() as stub: # Open grpc channel.
response = stub.GetCookies(
Request().Empty()
) # Call the cookies implementation from Node side.
cookies = json.loads(response.json) # Get json payload from response.
# Write Python code as you need, these lines are just examples.
for cookie in cookies:
if cookie["name"] == "Foo22":
return {"name": cookie["name"], "value": cookie["value"]}
return {}
def now_keyword(self): # This is not keyword
print(1)