Skip to content

Commit

Permalink
Merge pull request #164 from jdi-testing/1554-add-logs-for-determinin…
Browse files Browse the repository at this point in the history
…g-visibility-locators

1554-add-logs-for-determining-visibility-locators
  • Loading branch information
Ekaterina-Zykova authored Oct 17, 2023
2 parents e7c132c + 5e4f878 commit 84d9d29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/selenium_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

from app.logger import logger


def get_element_id_to_is_displayed_mapping(page_content_str):
chrome_options = Options()
Expand All @@ -22,15 +24,16 @@ def get_element_id_to_is_displayed_mapping(page_content_str):
wait = WebDriverWait(driver, 10)
wait.until(EC.presence_of_element_located((By.TAG_NAME, "body")))

all_elements = driver.find_elements(by=By.XPATH, value='//*')
all_elements = driver.find_elements(by=By.XPATH, value="//*")

result = {}

for element in all_elements:
element_id = element.get_attribute('jdn-hash') # got this format \"0000000000000000000000000000\"
element_id = element.get_attribute("jdn-hash") # got this format \"0000000000000000000000000000\"
element_id = str(element_id).replace('\\"', '') # need to remove \"
is_shown = element.is_displayed()
result[element_id] = is_shown
logger.info(f"Element with jdn-hash {element_id} {'Visible' if is_shown else 'Invisible'}")

driver.quit()
return result
Expand Down
2 changes: 2 additions & 0 deletions ds_methods/html5_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ async def html5_predict_elements(body):
del model
gc.collect()
result = results_df[columns_to_publish].to_dict(orient="records")

logger.info("Determining visibility locators")
element_id_to_is_displayed_map = get_element_id_to_is_displayed_mapping(document_json)
for element in result:
element["is_shown"] = element_id_to_is_displayed_map.get(element["element_id"], None)
Expand Down

0 comments on commit 84d9d29

Please sign in to comment.