mercredi 20 février 2019

How to make python script wait until entering specific URL

I want python script to be triggered by entering specific URLs with specific part of address.

Here is an example:

http://11.111.11.11:0000/Menu_EXAMPLE.jsp?NUMBER=1234
#1234 can be any random 4 digits Number

Basically I want python script to activate when URL has "http://11.111.11.11:0000/Menu_EXAMPLE.jsp?NUMBER=" in it.

Here is what I wrote so far:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

driver = webdriver.Chrome('./chromedriver')
wait = WebDriverWait(driver, 9999)
desired_url = http://11.111.11.11:0000/Menu_EXAMPLE.jsp?NUMBER=\d{4}
def wait_for_correct_current_url):
      wait.until(lambda driver: driver.current_url == desired_url)



driver.get("http://www.google.com")
wait_for_correct_current_url(desired_url)
**(Script that activates after entering desired_url)**

I am wondering if regex will do the trick, but I am new to python... so what do i know.

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire