pythonautomation

Log off (uitloggen) and log on


I'm making one reservation on this site https://bent.baanreserveren.nl/user/future after the first reservation has been made I have to log off an log on with a different name.

At this moment I use driver.close() after the first reservation and driver.get for starting the next reservation, this takes +/- 5 seconds. I think it would be faster to not use driver.close() but log off and log on. This is the element: <li class=""><a href="/auth/logout" class="">Uitloggen</a></li>

Unfortunately I didn't manage to log off (Uitloggen). enter image description here

Can somebody help me?

This is the class which I have to use:

1st level

XPath //*[@id="main-menu"]/li[7]

Selector: #main-menu > li:nth-child(7)

2nd level

XPath //*[@id="main-menu"]/li[7]/a

Selector: #main-menu > li:nth-child(7) > a

I'm using this within a python script and the url behind this uitloggen is: https://bent.baanreserveren.nl/auth/logout

I tried: element = element = driver.find_element(By.XPATH, '//*[@id="main-menu"]/li[7]/a') element.click()

and element = driver.find_element(By.XPATH, '//*[@id="main-menu"]/li[7]/a') element.click()

Both of them are not directing to to log out url


Solution

  • I did manage it with this code:

    menu_item = driver.find_element(By.XPATH, '//*[@id="main-menu"]/li[7]')
    menu_item.click()
    

    It is working.