Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

How to avoid duplication of records in a database

View previous topic View next topic Go down

How to avoid duplication of records in a database

Post by bharathip on 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

bharathip

Posts : 8
Join date : 2011-11-08

Back to top Go down

Re: How to avoid duplication of records in a database

Post by faramka on 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!");
}

faramka
Professional
Professional

Posts : 143
Join date : 2011-09-15
Location : Poland

Back to top Go down

Re: How to avoid duplication of records in a database

Post by bharathip on 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);


bharathip

Posts : 8
Join date : 2011-11-08

Back to top Go down

Re: How to avoid duplication of records in a database

Post by faramka on 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

faramka
Professional
Professional

Posts : 143
Join date : 2011-09-15
Location : Poland

Back to top Go down

Re: How to avoid duplication of records in a database

Post by bharathip on Tue Nov 08, 2011 7:30 pm

id..i used id as locator..

bharathip

Posts : 8
Join date : 2011-11-08

Back to top Go down

Re: How to avoid duplication of records in a database

Post by faramka on 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))

faramka
Professional
Professional

Posts : 143
Join date : 2011-09-15
Location : Poland

Back to top Go down

Re: How to avoid duplication of records in a database

Post by bharathip on Wed Nov 09, 2011 11:26 am



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


Sad

bharathip

Posts : 8
Join date : 2011-11-08

Back to top Go down

Re: How to avoid duplication of records in a database

Post by faramka on 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.

faramka
Professional
Professional

Posts : 143
Join date : 2011-09-15
Location : Poland

Back to top Go down

Re: How to avoid duplication of records in a database

Post by bharathip on 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..

bharathip

Posts : 8
Join date : 2011-11-08

Back to top Go down

Re: How to avoid duplication of records in a database

Post by faramka on 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

faramka
Professional
Professional

Posts : 143
Join date : 2011-09-15
Location : Poland

Back to top Go down

Re: How to avoid duplication of records in a database

Post by bharathip on 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

bharathip

Posts : 8
Join date : 2011-11-08

Back to top Go down

Re: How to avoid duplication of records in a database

Post by faramka on Mon Nov 14, 2011 2:59 pm

OK, fine.
And thanks for sharing this solution Smile

faramka
Professional
Professional

Posts : 143
Join date : 2011-09-15
Location : Poland

Back to top Go down

Re: How to avoid duplication of records in a database

Post by Sponsored content Today at 3:25 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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