Python Forum
Python Selenium .click() Loads Error - Works Manually.- Events not Triggered
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Selenium .click() Loads Error - Works Manually.- Events not Triggered
#9
Sorry my fault.

Is there any way we can view your full code with access to this webpage and the element you are having trouble with? Or is that not possible?

(Jul-30-2019, 12:43 PM)NSearch Wrote: When I do the exact same thing manually
Is this manually in the selenium browser or your own?

Are you passing any cookies beforehand?
import requests
from selenium import webdriver

driver = webdriver.Firefox()
url = "some_url" #a redirect to a login page occurs
driver.get(url)

#storing the cookies generated by the browser
request_cookies_browser = driver.get_cookies()

#making a persistent connection using the requests library
params = {'os_username':'username', 'os_password':'password'}
s = requests.Session()

#passing the cookies generated from the browser to the session
c = [s.cookies.set(c['name'], c['value']) for c in request_cookies_browser]

resp = s.post(url, params) #I get a 200 status_code

#passing the cookie of the response to the browser
dict_resp_cookies = resp.cookies.get_dict()
response_cookies_browser = [{'name':name, 'value':value} for name, value in dict_resp_cookies.items()]
c = [driver.add_cookie(c) for c in response_cookies_browser]

#the browser now contains the cookies generated from the authentication    
driver.get(url)

#now find and press your button
Recommended Tutorials:
Reply


Messages In This Thread
RE: Python Selenium .click() Loads Error - Works Manually.- Events not Triggered - by metulburr - Jul-30-2019, 10:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Selenium - Error writing in field brunox96 1 1,418 Nov-22-2024, 03:28 PM
Last Post: andraee
  Click on a button on web page using Selenium Pavel_47 7 7,111 Jan-05-2023, 04:20 AM
Last Post: ellapurnellrt
  Show HTML in Python application and handle click SamHobbs 2 3,843 Sep-28-2021, 06:27 PM
Last Post: SamHobbs
  Selenium/Helium loads up a blank web page firaki12345 0 2,703 Mar-23-2021, 11:51 AM
Last Post: firaki12345
  button click error rafarangel 2 3,937 Feb-11-2021, 08:19 PM
Last Post: buran
  Log In Button Won't Click - Python Selenium Webdriver samlee916 2 4,848 Jun-07-2020, 04:42 PM
Last Post: samlee916
  Hyperlink Click is not working in Selenium webdriver rajeev1729 0 2,474 May-02-2020, 11:21 AM
Last Post: rajeev1729
  selenium click in iframe fails 3Pinter 6 7,415 Apr-29-2020, 12:59 PM
Last Post: Larz60+
  Selenium weird error julio2000 0 2,246 Feb-23-2020, 01:24 PM
Last Post: julio2000
  Selenium webdriver error WiPi 4 15,226 Feb-09-2020, 11:38 AM
Last Post: WiPi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020