Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Selenium Page Tracking

Ways to detect Page Change:
  • Use an explicit wait with an expected condition 
  • While(self.driver.getCurrentUrl() != nextPageUrl) :sleep(2) #if url change
  • By checking Title tag if it changes

CustomTracking
Using Console
localStorage.a=0;

TamperMonkey
//for the whole domain
localStorage.a++;

Python: [selq]
#For explicit wait 
WebDriverWait(b, 5).until(
EC.presence_of_element_located((By.CSS_SELECTOR,'#s')))
WebDriverWait(b, 5).until(
EC.invisibility_of_element_located((By.CSS_SELECTOR,'#s')))

from selq import this
window_changed=bes('return +localStorage.a')
def iswc():
global window_changed
a=bes('return +localStorage.a')
for i in range(10):
if window_changed return True
sleep(2)
alert('Hey Baby')
exit()


This post first appeared on SMARTMANOJ, please read the originial post: here

Share the post

Selenium Page Tracking

×

Subscribe to Smartmanoj

Get updates delivered right to your inbox!

Thank you for your subscription

×