Skip to content

Commit 04feebe

Browse files
committed
fix piece with picle file
1 parent ad625c6 commit 04feebe

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

pieces/SeleniumWebBrowserPiece/piece.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from selenium.webdriver.common.by import By
66
from pathlib import Path
77
from typing import List
8-
import json
8+
import uuid
9+
import pickle
10+
911
class SeleniumWebBrowserPiece(BasePiece):
1012

1113
def piece_function(self, input_data: InputModel):
@@ -22,6 +24,8 @@ def piece_function(self, input_data: InputModel):
2224

2325
self.driver.quit()
2426

27+
self.logger.info(f"Outputs: {outputs}")
28+
2529
return OutputModel(
2630
outputs=outputs
2731
)
@@ -52,9 +56,18 @@ def run_commands(self, commands: List[CommandInput]) -> List[str]:
5256

5357
if cmd.name.value == "find_elements_css":
5458
elements = self.driver.find_elements(By.CSS_SELECTOR, cmd.value)
55-
result = []
59+
self.logger.info(f"elements: {len(elements)}")
60+
file_name = f"{results_path}/{uuid.uuid4()}.pkl"
61+
62+
content = list()
63+
5664
for e in elements:
57-
result.append(e.get_attribute('innerHTML'))
65+
content.append(e.get_attribute("innerHTML"))
66+
67+
with open(file_name,"wb") as file:
68+
pickle.dump(content, file)
69+
70+
result = file_name
5871

5972
if not isinstance(result,str):
6073
result = str(result)

0 commit comments

Comments
 (0)