<div dir="ltr"><div dir="ltr">Sounds like Cross-Site Request Forgery (CSRF) protection toke, if you make the request to login without it what gets returned? When I worked on that stuff when we got a request with out a token we would return a token and say repeat.</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Sep 17, 2018 at 4:21 PM Marc Lytle via SGVLUG <<a href="mailto:sgvlug@sgvlug.net">sgvlug@sgvlug.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>My name is Marc and I'm helping Chime Hart, from this last week's sgvlug, with his systems. We are trying to log into a website with selenium and having a bit of trouble. It was suggested I email this group with the specifics of the problems we've been having. Below is some code I have used:</div><div><br></div><div><div>#!/usr/bin/env python</div><div>from selenium import webdriver</div><div>from selenium.webdriver.firefox.options import Options</div><div>from selenium.webdriver.support.ui import WebDriverWait as wait</div><div>from selenium.webdriver.support import expected_conditions as EC<br></div><div><br></div><div>options = Options()</div><div># options.set_headless(headless=True)</div><div><br></div><div>driver = webdriver.Firefox(firefox_options=options, executable_path=r'/usr/local/bin/geckodriver')</div><div>def i24_login():</div><div> driver.get ('<a href="https://video.i24news.tv/" target="_blank">https://video.i24news.tv/</a>')</div><div> driver.find_element_by_xpath('//*[@id="app"]/div/div/div[1]/div/nav[1]/div/div[3]/div[2]/button').click()</div><div> # This line returns True when printed, but doesn't see accessable in any meaningfull way</div><div> # bob = wait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it(driver.find_element_by_xpath('//iframe[contains(@src, "auth/2/purchase")]')))</div><div> # This line throws an unfound error even though the radio button's id is authType-1.</div><div> bob = wait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it(driver.find_element_by_id('authType-1') ))</div><div> </div><div> print bob</div><div><br></div><div><br></div><div>i24_login()</div><div><br></div><div>print ("Headless Firefox Initialized")</div></div><div><br></div><div>It opens the site and clicks the login, but neither wait lines above results in an object of which I can do anything. 'authType-1' is a radio button necessary to login and not register as a new user. If anyone can find a way to access that, then I could easily enter his information to the login. </div><div><br></div><div>As far as the actual login request goes, it works through a third party (<a href="http://cleeng.com" target="_blank">cleeng.com</a>) and seems to be a simple API call. I've watched the login process itself from an open browser inspecting the network traffic, but the login in request seems to have an auto-generated key/token that is created for each request. I was hoping that I could just script the login and inject the token, but I haven't found a way to predict that key yet. </div><div><br></div><div>Any help or suggestions would be greatly appreciated. </div><div>-- </div><div dir="ltr" class="m_-4172268544229186177gmail_signature"><div dir="ltr">Marc Lytle<br></div></div></div></div>
</blockquote></div>