Skip to content

Commit

Permalink
Update click with action chain to see gclid in url
Browse files Browse the repository at this point in the history
  • Loading branch information
coskundeniz committed Jun 25, 2023
1 parent 61d952a commit 63314c7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion search_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from time import sleep

import selenium
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
Expand Down Expand Up @@ -137,12 +138,21 @@ def click_ads(self, ads: AdList) -> None:
logger.info(f"Clicking to [{ad_title}]({ad_link})...")

# open link in a different tab
ad_link_element.send_keys(Keys.CONTROL + Keys.RETURN)
actions = ActionChains(self._driver)
actions.move_to_element(ad_link_element)
actions.key_down(Keys.CONTROL)
actions.click()
actions.key_up(Keys.CONTROL)
actions.perform()
sleep(0.5)

for window_handle in self._driver.window_handles:
if window_handle != original_window_handle:
self._driver.switch_to.window(window_handle)
sleep(self._ad_visit_time)

logger.debug(f"Current url on new tab: {self._driver.current_url}")

self._driver.close()
break

Expand Down

0 comments on commit 63314c7

Please sign in to comment.