Skip to content

Commit c388503

Browse files
committed
Refactored take screenshot and remove color functions
1 parent 8a5ff05 commit c388503

2 files changed

Lines changed: 20 additions & 26 deletions

File tree

.github/scripts/build_assets/SeleniumRunner.py

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def upload_svgs(self, svgs: List[str], screenshot_folder: str=""):
143143
import_btn.send_keys(svgs[i])
144144
print(f"Uploaded {svgs[i]}")
145145
self.test_for_possible_alert(self.SHORT_WAIT_IN_SEC, "Dismiss")
146-
self.remove_color_from_icon(screenshot_folder, i)
146+
self.click_on_just_added_icon(screenshot_folder, i)
147147

148148
# take a screenshot of the icons that were just added
149149
new_icons_path = str(Path(screenshot_folder, "new_icons.png").resolve())
@@ -199,50 +199,44 @@ def test_for_possible_alert(self, wait_period: float, btn_text: str):
199199
except SeleniumTimeoutException:
200200
pass # nothing found => everything is good
201201

202-
def remove_color_from_icon(self, screenshot_folder: str, index: int):
202+
def click_on_just_added_icon(self, screenshot_folder: str, index: int):
203203
"""
204-
Remove the color from the most recent uploaded icon.
205-
:param screenshot_folder: the name of the screenshot_folder. If
206-
the value is provided, it means the user want to take a screenshot
207-
of each icon.
208-
:param index, index of the icon being uploaded. Used for naming the screenshot.
209-
:return: None.
204+
Click on the most recently added icon so we can remove the colors
205+
and take a snapshot if needed.
210206
"""
211207
try:
212208
recently_uploaded_icon = WebDriverWait(self.driver, self.LONG_WAIT_IN_SEC).until(
213209
ec.element_to_be_clickable((By.XPATH, "//div[@id='set0']//mi-box[1]//div"))
214210
)
215211
recently_uploaded_icon.click()
216-
except Exception as e:
217-
self.close()
218-
raise e
219-
220-
try:
221-
color_tab = WebDriverWait(self.driver, self.SHORT_WAIT_IN_SEC).until(
222-
ec.element_to_be_clickable((By.CSS_SELECTOR, "div.overlayWindow i.icon-droplet"))
223-
)
224-
color_tab.click()
225212

226-
remove_color_btn = self.driver \
227-
.find_element_by_css_selector("div.overlayWindow i.icon-droplet-cross")
228-
remove_color_btn.click()
213+
self.remove_color_from_icon()
229214

230-
# take a screenshot before closing the pop up
231215
if screenshot_folder:
232216
screenshot_path = str(Path(screenshot_folder, f"screenshot_{index}.png").resolve())
233217
self.driver.save_screenshot(screenshot_path)
234-
except Exception as e:
235-
self.close()
236-
raise e
218+
print("Took screenshot and saved it at " + screenshot_path)
237219

238-
try:
239220
close_btn = self.driver \
240221
.find_element_by_css_selector("div.overlayWindow i.icon-close")
241222
close_btn.click()
242223
except Exception as e:
243224
self.close()
244225
raise e
245226

227+
def remove_color_from_icon(self):
228+
"""
229+
Remove the color from the most recent uploaded icon.
230+
"""
231+
color_tab = WebDriverWait(self.driver, self.SHORT_WAIT_IN_SEC).until(
232+
ec.element_to_be_clickable((By.CSS_SELECTOR, "div.overlayWindow i.icon-droplet"))
233+
)
234+
color_tab.click()
235+
236+
remove_color_btn = self.driver \
237+
.find_element_by_css_selector("div.overlayWindow i.icon-droplet-cross")
238+
remove_color_btn.click()
239+
246240
def download_icomoon_fonts(self, zip_path: Path):
247241
"""
248242
Download the icomoon.zip from icomoon.io.

.github/scripts/icomoon_peek.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def main():
3131
runner = None
3232
try:
3333
runner = SeleniumRunner(args.download_path, args.geckodriver_path, args.headless)
34-
svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path)
34+
svgs = filehandler.get_svgs_paths(filtered_icons, args.icons_folder_path)
3535
runner.upload_svgs(svgs, screenshot_folder)
3636
print("Task completed.")
3737
except TimeoutException as e:

0 commit comments

Comments
 (0)