Skip to content

Commit

Permalink
Update selenium.py
Browse files Browse the repository at this point in the history
make format action
  • Loading branch information
chengxuan-xia authored Aug 3, 2023
1 parent a876bf5 commit 286e100
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions chromegpt/tools/selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def scroll(self, direction: str) -> str:

def _get_website_main_content(self, soup: BeautifulSoup) -> str:
texts = [
element.get_text(separator=' ') for element in soup.find_all(string=True)
element.get_text(separator=" ") for element in soup.find_all(string=True)
]
pretty_texts = [prettify_text(text) for text in texts]
if not pretty_texts:
Expand All @@ -339,8 +339,8 @@ def _get_interactable_elements(self, soup: BeautifulSoup) -> str:
or (tag.name == "div" and tag.get("role") == "button")
or tag.name == "a"
or (
tag.name == "input"
and tag.get("type")
tag.name == "input"
and tag.get("type")
in ["checkbox", "submit", "button", "radio", "reset"]
)
or tag.has_attr("data-href")
Expand All @@ -352,10 +352,7 @@ def _get_interactable_elements(self, soup: BeautifulSoup) -> str:
# Detect if size is visible
if element.get("style") and "display: none" in element.get("style"):
continue
if (
"style" in element.attrs
and "display: none" in element["style"]
):
if "style" in element.attrs and "display: none" in element["style"]:
continue

button_text = (
Expand All @@ -367,7 +364,9 @@ def _get_interactable_elements(self, soup: BeautifulSoup) -> str:
)

if button_text:
button_text = prettify_text(button_text, limit=50, remove_special_char=True)
button_text = prettify_text(
button_text, limit=50, remove_special_char=True
)
if button_text not in interactable_texts:
interactable_texts.append(button_text)

Expand Down

0 comments on commit 286e100

Please sign in to comment.