Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96594 > unrolled thread

need help with selenium

Started byshiva upreti <katewinslet626@gmail.com>
First post2015-09-14 12:40 -0700
Last post2015-09-15 14:18 +0200
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  need help with selenium shiva upreti <katewinslet626@gmail.com> - 2015-09-14 12:40 -0700
    {Spam?} Re: need help with selenium Nagy László Zsolt <gandalf@shopzeus.com> - 2015-09-15 14:18 +0200

#96594 — need help with selenium

Fromshiva upreti <katewinslet626@gmail.com>
Date2015-09-14 12:40 -0700
Subjectneed help with selenium
Message-ID<bb6cf5b7-71f4-445e-8cdc-04259ddb77fb@googlegroups.com>
I wrote this code in python for submitting a login form: 

<code> 
from selenium import webdriver 
from selenium.webdriver.common.keys import Keys 
driver = webdriver.Firefox() 

driver.get('some url') 

elem = driver.find_element_by_name("username") 
elem.send_keys('13103666') 
elem = driver.find_element_by_name("password") 
elem.send_keys('as') 
driver.find_element_by_name("btnSubmit").click() 
#nothing happens from here 
print driver.page_source 
print "test" 
</code> 

After clicking on submit button, a message is displayed on the same page whether login was successful or not. 
However after clicking on submit button, I lose control over the web page. I can't use any selenium functions now like 'driver.find_element_by_name()'. 

Initially everything works fine. I can enter username and password using selenium as written in my code, but once I click on submit button or press return key(tried both using selenium), any script written after that(involving web driver) doesnt seem to work. Even driver.close() doesnt work. 
This is the form I am trying to submit: 
<form name="frmHTTPClientLogin" target="_parent" method="post" onsubmit="return checkSubmit();" action="httpclient.html"> 

The submission is successful, however after submission I cant verify if login was successful or not because of the issue I posted above. 
Do I need to switch web handle? If, then how. 

Any help will be highly appreciated. 

[toc] | [next] | [standalone]


#96631 — {Spam?} Re: need help with selenium

FromNagy László Zsolt <gandalf@shopzeus.com>
Date2015-09-15 14:18 +0200
Subject{Spam?} Re: need help with selenium
Message-ID<mailman.593.1442320080.8327.python-list@python.org>
In reply to#96594
> After clicking on submit button, a message is displayed on the same page whether login was successful or not.
> However after clicking on submit button, I lose control over the web page. I can't use any selenium functions now like 'driver.find_element_by_name()'.
You need to wait until the submit completes. Firefox works in paralel in 
the background, so don't expect the new page to be loaded right after 
you called .submit().

One way to do it is this: after calling submit, call this:

self.browser.find_element_by_tag_name("body")

This call will return ONLY if the page has completed loading. Then you 
can get page_source or do whatever you want.



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web