losing control after clicking button

88 views
Skip to first unread message

shiva upreti

unread,
Sep 13, 2015, 8:59:58 AM9/13/15
to Selenium Users
I wrote this code in python for submitting a login form:

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"

After clicking on submit button, a message is displayed on the same page whether login was successful or not. I think the request was submitted using javascript.
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()'.
Do I need to switch web handle? If, then how.

Any help will be highly appreciated.



Kurniawan Putra

unread,
Sep 13, 2015, 9:51:04 PM9/13/15
to Selenium Users
Hi shiva,

if element by name is not working please using xpath.
you can changes via selenkum IDE.
"driver.findElement(By.xpath("//a[contains(text(),'Login')]")).click();"


Auto Generated Inline Image 1

shiva upreti

unread,
Sep 14, 2015, 4:38:37 AM9/14/15
to Selenium Users
Hi
Thanks for the response.
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.
Please help..!! I am stuck.
Reply all
Reply to author
Forward
0 new messages