Skip to content

Commit b40e162

Browse files
ZeuZ AgentZeuZ Agent
andcommitted
docs: update instruction files to reflect recent changes
Co-Authored-By: ZeuZ Agent <info@zeuz.ai>
1 parent 01f97e7 commit b40e162

2 files changed

Lines changed: 42 additions & 37 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ Variables use `%|variable_name|%` syntax:
146146
"%|user["name"]|%" # Dictionary access
147147
```
148148

149+
Some Selenium actions, including `copy image into browser`, accept a single input row that can contain either a literal path or a `%|...|%` reference because the framework resolves it before the action runs.
150+
149151
### Element Location
150152
The unified `LocateElement.Get_Element()` supports:
151153
- Selenium WebDriver

Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5155,17 +5155,12 @@ def if_element_exists(data_set):
51555155
@logger
51565156
def copy_image_into_browser(data_set):
51575157
"""
5158-
This action will copy an image from path or a variable into browser, and later you can paste via ctrl+v or cmd+v.
5158+
This action will copy an image from path or a shared variable into browser, and later you can paste via ctrl+v or cmd+v.
51595159
Supported formats: PNG, SVG
51605160
5161-
Example 1:
5162-
Field Sub Field Value
5163-
image file input parameter %| image.png |%
5164-
copy image into browser selenium action copy image into browser
5165-
5166-
Example 2:
5161+
Example:
51675162
Field Sub Field Value
5168-
image variable input parameter %| image_var |%
5163+
image file input parameter %| image_var |%
51695164
copy image into browser selenium action copy image into browser
51705165
"""
51715166
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
@@ -5174,7 +5169,6 @@ def copy_image_into_browser(data_set):
51745169
try:
51755170
image_data = None
51765171
image_path = ""
5177-
variable_name = ""
51785172
mime_type = "image/png"
51795173

51805174
# Parse
@@ -5184,35 +5178,36 @@ def copy_image_into_browser(data_set):
51845178
right = right.strip()
51855179

51865180
if left == "imagefile":
5187-
if os.path.exists(right):
5188-
image_path = right
5189-
else:
5190-
image_path = CommonUtil.path_parser(right)
5181+
image_path = right
51915182

5192-
elif left == "imagevariable":
5193-
if os.path.exists(right):
5194-
image_path = right
5195-
else:
5196-
variable_name = right
5183+
if not image_path:
5184+
CommonUtil.ExecLog(
5185+
sModuleInfo, "Must provide 'image file' for copy image into browser", 3
5186+
)
5187+
return "zeuz_failed"
51975188

5198-
if image_path:
5199-
if not os.path.exists(image_path):
5200-
CommonUtil.ExecLog(
5201-
sModuleInfo, f"Image file not found: {image_path}", 3
5202-
)
5203-
return "zeuz_failed"
5204-
elif variable_name:
5205-
image_path = Shared_Resources.Get_Shared_Variables(variable_name)
5206-
if not image_path:
5207-
CommonUtil.ExecLog(
5208-
sModuleInfo,
5209-
f"Image path not found in variable: {variable_name}. Make sure you must be use '%| |%' syntax for any variable or attachment.",
5210-
3,
5211-
)
5212-
return "zeuz_failed"
5213-
else:
5189+
image_path = CommonUtil.path_parser(image_path)
5190+
if not image_path:
52145191
CommonUtil.ExecLog(
5215-
sModuleInfo, "Must provide either 'image file' or 'image variable'", 3
5192+
sModuleInfo,
5193+
"Image path resolved to an empty value. Check the 'image file' input.",
5194+
3,
5195+
)
5196+
return "zeuz_failed"
5197+
5198+
if not os.path.exists(image_path):
5199+
CommonUtil.ExecLog(
5200+
sModuleInfo,
5201+
f"Image file not found or unreadable: {image_path}",
5202+
3,
5203+
)
5204+
return "zeuz_failed"
5205+
5206+
if not os.path.isfile(image_path):
5207+
CommonUtil.ExecLog(
5208+
sModuleInfo,
5209+
f"Image path is not a file: {image_path}",
5210+
3,
52165211
)
52175212
return "zeuz_failed"
52185213

@@ -5228,8 +5223,16 @@ def copy_image_into_browser(data_set):
52285223
)
52295224
return "zeuz_failed"
52305225

5231-
with open(image_path, "rb") as image_file:
5232-
image_data = image_file.read()
5226+
try:
5227+
with open(image_path, "rb") as image_file:
5228+
image_data = image_file.read()
5229+
except OSError as exc:
5230+
CommonUtil.ExecLog(
5231+
sModuleInfo,
5232+
f"Unable to read image file '{image_path}': {exc}",
5233+
3,
5234+
)
5235+
return "zeuz_failed"
52335236

52345237
# Convert
52355238
image_b64 = base64.b64encode(image_data).decode("utf-8")

0 commit comments

Comments
 (0)