Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
bharathip
Posts : 8
Join date : 2011-11-08

How to avoid duplication of records in a database Empty How to avoid duplication of records in a database

Tue Nov 08, 2011 3:44 pm
Hi all,
I am using selenium RC with testng. writing scripts in java.
i m testing a web application. In that duplication of a record is not allowed.
I am passing records through xls using data provider.

In the application, if we enter same name for another record and click on another field,it will show a message that record already exists..!! on the top of the field name itself.
when i use istextpresent(); it is not detecting that msg while running the test Script..
and allowing duplication of records. i found two records with same content in database after running test script.

can any one tell me how to resolve this issue.


Last edited by bharathip on Wed Nov 09, 2011 11:33 am; edited 1 time in total
avatar
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

How to avoid duplication of records in a database Empty Re: How to avoid duplication of records in a database

Tue Nov 08, 2011 5:18 pm
How exactly do you use isTextPresent() ? You should use it with if statement (for my code in PHP with PHPUnit):
Code:
if ($this->isTextPresent("Record already exists!") {
    $this->fail("Attempt to duplicate the record!");
}
Another way you can do it with using assertElementNotPresent() and try/catch:
Code:
try {
        $this->assertTextNotPresent("Record already exists!") {
} catch (Exception $e) {
        $this->fail("Attempt to duplicate the record!");
}
avatar
bharathip
Posts : 8
Join date : 2011-11-08

How to avoid duplication of records in a database Empty Re: How to avoid duplication of records in a database

Tue Nov 08, 2011 6:13 pm
Screen consists of two fields Name and Remarks
Entered name field, and clicked on remarks field. If name already exists a warning appears above the name field "name already exists..!!"
but while running test script that warning is not getting generated by clicking on remarks field.
//Below is my code.//

selenium.type("id=name field id",name);
selenium.click(" fieid=remarksld id",remarks );

if(selenium.isTextPresent("Name already exists"))
{
throw new SkipException("Record already exists..!!");
}
selenium.type("fieid=remarksld id",remarks);

avatar
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

How to avoid duplication of records in a database Empty Re: How to avoid duplication of records in a database

Tue Nov 08, 2011 7:27 pm
bharathip wrote:selenium.click(" fieid=remarksld id",remarks );

At first you should change the above line, because click() takes one parameter (element's locator in the following form: locatorType=argument). And could you please tell what type of locator do you try to use by writing fieid? As I know, there are locators: id, identifier, name, dom, xpath, link, css.


Last edited by faramka on Tue Nov 08, 2011 7:30 pm; edited 1 time in total
avatar
bharathip
Posts : 8
Join date : 2011-11-08

How to avoid duplication of records in a database Empty Re: How to avoid duplication of records in a database

Tue Nov 08, 2011 7:30 pm
id..i used id as locator..
avatar
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

How to avoid duplication of records in a database Empty Re: How to avoid duplication of records in a database

Tue Nov 08, 2011 7:43 pm
OK, so you can also put into click() just "elementId".
For example:
For an element:
Code:
< in_put id="first-name" name="user-first-name" />
(I added "_" to set this code as text)
method will be look like:
Code:
selenium.click("first-name");
d
When you don't set the type of locator, it is id by default.

This is simplification of the code Smile


Last edited by faramka on Tue Nov 08, 2011 7:47 pm; edited 1 time in total (Reason for editing : (I added "_" to set this code as text))
avatar
bharathip
Posts : 8
Join date : 2011-11-08

How to avoid duplication of records in a database Empty Re: How to avoid duplication of records in a database

Wed Nov 09, 2011 11:26 am


Still now my problem is not resolved yet.. can anyone help me..!!!!


Sad
avatar
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

How to avoid duplication of records in a database Empty Re: How to avoid duplication of records in a database

Wed Nov 09, 2011 8:02 pm
Maybe after putting a text in name field you should click outside the name field and then check if there a message is displayed.
avatar
bharathip
Posts : 8
Join date : 2011-11-08

How to avoid duplication of records in a database Empty Re: How to avoid duplication of records in a database

Thu Nov 10, 2011 11:08 am
If i click out the field manually, Text is appearing.

Through automation it is not working.Warning text itself is not appearing. How can selenium can detect the text..?
I am not able to understand what i should do..
avatar
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

How to avoid duplication of records in a database Empty Re: How to avoid duplication of records in a database

Thu Nov 10, 2011 2:22 pm
Try click not manually but by simulating with Selenium!

1. type a text in name field
2. click at any other element
3. verify if the message is displayed
avatar
bharathip
Posts : 8
Join date : 2011-11-08

How to avoid duplication of records in a database Empty Re: How to avoid duplication of records in a database

Fri Nov 11, 2011 12:18 pm
I got the solution for this...

After the entering the name , performing click operation on the other field through selenium. that warning is not appearing.

use -> selenium.fireEvent("id of the name field","onblur");

Write the above statement after entering the name in selenium test script.

thank u... Very Happy
avatar
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

How to avoid duplication of records in a database Empty Re: How to avoid duplication of records in a database

Mon Nov 14, 2011 2:59 pm
OK, fine.
And thanks for sharing this solution Smile
Sponsored content

How to avoid duplication of records in a database Empty Re: How to avoid duplication of records in a database

Back to top
Permissions in this forum:
You cannot reply to topics in this forum