- flower07
- Posts : 3
Join date : 2011-08-05
Exported Selenium Script Throws Exception
Fri Sep 02, 2011 5:00 pm
I recorded an action using the Selenium IDE and used the File->Export Test Cases as Python 2 (Remote Control) format.
I am using Selenium RC 2.3.0
I then ran the script from command prompt but it throws an exception.
The exported Python 2 RC code is:
At this line - sel.click("link=Home") it fails with the exception
I even tried increasing the 30000 to 60000 but still no help. I can see
the page is loaded fully and waiting for a while because of the higher
timeout. However when executing this link=Home it fails.
The HTML code is:
I did run the test using IDE's recorded script. It works great. I was
able to login and click on the Home link too. However, it fails with
that exception when I wanted to run it using Python's Unittest with
Selenium Server 2.3.0.
I tried sel.click('//a[contains(text((),"Home")]') and it throws the exception
I even tried sel.click('xpath=//a[contains(text((),"Home")]') and it
still throws the same exception as mentioned in the above comment. I
wonder what could be wrong. If I comment the line that clicks on the
Home link then it runs fine. Its the problem with clicking this link.
To add, not only for Home. It does not work for Home or Setup or even
Signout for that matter. It does not work for any of the links in that
div. However playing back the recorded script works fine!
Any suggestions or guidance, please?
I am using Selenium RC 2.3.0
I then ran the script from command prompt but it throws an exception.
The exported Python 2 RC code is:
- Code:
from selenium import selenium
import unittest, time, re
class login(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", 4444, "*chrome", "http://
testServer1/")
self.selenium.start()
def test_login(self):
sel = self.selenium
sel.open("/WebAccess/login.html")
sel.type("id=LoginID", "Administrator")
sel.type("id=Password", "Administrator")
sel.click("id=login")
sel.wait_for_page_to_load("30000")
sel.click("link=Home") # This is where it fails.
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
At this line - sel.click("link=Home") it fails with the exception
- Code:
======================================================================
ERROR: test_login (__main__.login)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Documents and Settings\User\Desktop\login.py", line 16, in
test_log
in
sel.click("link=Home")
File "C:\Python27\lib\selenium\selenium.py", line 290, in click
self.do_command("click", [locator,])
File "C:\Python27\lib\selenium\selenium.py", line 217, in do_command
raise Exception, data
Exception: ERROR: Element link=Home not found
----------------------------------------------------------------------
I even tried increasing the 30000 to 60000 but still no help. I can see
the page is loaded fully and waiting for a while because of the higher
timeout. However when executing this link=Home it fails.
The HTML code is:
- Code:
<div class="links nopreview">
<span><a class="csiAction" href="/WebAccess/home.html#URL=centric://
REFLECTION/INSTANCE/_CS_Data/null">Home</a></span>
<span> • </span>
<span><span><a class="csiAction" href="/WebAccess/
home.html#URL=centric://SITEADMIN/_CS_Site">Setup</a>
</span><span> • </span>
</span><span><a title="Sign Out" class="csiAction csiActionLink">Sign
Out</a></span>
</div>
- Code:
<tr>
<td>open</td>
<td>/WebAccess/login.html</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=LoginID</td>
<td>Administrator</td>
</tr>
<tr>
<td>type</td>
<td>id=Password</td>
<td>Administrator</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=login</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>link=Home</td>
<td></td>
</tr>
I did run the test using IDE's recorded script. It works great. I was
able to login and click on the Home link too. However, it fails with
that exception when I wanted to run it using Python's Unittest with
Selenium Server 2.3.0.
I tried sel.click('//a[contains(text((),"Home")]') and it throws the exception
- Code:
Traceback (most recent call last): File "C:\Documents and
Settings\User\Desktop\login.py", line 17, in test_log in
sel.click('//a[contains(text((),"Home")]') File
"C:\Python27\lib\selenium\selenium.py", line 290, in click
self.do_command("click", [locator,])
File "C:\Python27\lib\selenium\selenium.py", line 217, in do_command raise Exception, data Exception:
ERROR: Invalid xpath [2]: //a[contains(text((),"Home")]
I even tried sel.click('xpath=//a[contains(text((),"Home")]') and it
still throws the same exception as mentioned in the above comment. I
wonder what could be wrong. If I comment the line that clicks on the
Home link then it runs fine. Its the problem with clicking this link.
To add, not only for Home. It does not work for Home or Setup or even
Signout for that matter. It does not work for any of the links in that
div. However playing back the recorded script works fine!
Any suggestions or guidance, please?
- Error : I could not able to switch parent window to overlay window because that it throws No element exception found. We are using the webdriver :- 2.45.1 Please some one can help to resolve this issue, thanks in advance.
- Selenium-Servr_2_5_0.jar throws error in RemoteControlConfiguration
- selenium RC exception
- selenium script
- selenium script
Permissions in this forum:
You cannot reply to topics in this forum