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 get data dynamically from Notepad file

View previous topic View next topic Go down

how to get data dynamically from Notepad file

Post by tweety on Tue Jul 10, 2012 7:44 pm

Hi All,

I have two variables declared in notepad with multiple values.How can I get those values in testscript of Selenium and compare it and add those values only if they are equal.

Can anyone please suggest me on this.



Regards

Tweety

tweety

Posts : 1
Join date : 2012-07-10

Back to top Go down

Re: how to get data dynamically from Notepad file

Post by ashish_gangwar on Wed Aug 08, 2012 1:57 pm

1. You can use Java Script. Either Embedded js in IDE directly or write an extention.
2. Write code in Java and call it through FIT which can be called from IDE

ashish_gangwar

Posts : 5
Join date : 2012-08-06
Age : 39
Location : Noida

Back to top Go down

Re: how to get data dynamically from Notepad file

Post by sanjeetravi on Thu Aug 09, 2012 12:24 pm

import com.thoughtworks.selenium.*;

import org.testng.annotations.*;

import static org.testng.Assert.*;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Reserve_Type_Add extends SeleneseTestNgHelper {

@BeforeClass
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost:7001/");
selenium.start();
}
@Test public void testAbc() throws Exception {


try {

FileInputStream fstream = new FileInputStream(
"C:\\Documents and Settings\\mann\\Desktop\\Add_New_Reserve_Type.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
// Read File Line By Line
while ((strLine = br.readLine()) != null)
{
String strline1[] = strLine.split(",");



selenium.open("/SimonWeb/login.html");
selenium.click("id=submit");
selenium.waitForPageToLoad("50000");
selenium.open("/SimonWeb/home.jsf");
selenium.click("//div[@id='dynamicMenuform:Reserve_Type']/span[2]");
selenium.waitForPageToLoad("50000");
selenium.click("id=searchForm:j_idt71");

for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if (selenium.isTextPresent("Code")) break; } catch (Exception e) {}
Thread.sleep(1000);
}

for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if (selenium.isTextPresent("Formula Description")) break; } catch (Exception e) {}
Thread.sleep(1000);
}


selenium.type("id=addEditForm:reserveCode", strline1[0]);
selenium.select("id=addEditForm:reserveType", "label=Computation Logic");
selenium.type("id=addEditForm:reserveTypeDesc", strline1[1]);
selenium.type("id=addEditForm:reserveValue1", strline1[2]);
selenium.type("id=addEditForm:reserveValue2", strline1[3]);
selenium.type("id=addEditForm:reserveValue3", strline1[4]);
selenium.type("id=addEditForm:reserveValue4", strline1[5]);
selenium.click("id=addEditForm:j_idt336");
selenium.click("id=addEditForm:popUpButton");
System.out.println(strline1[0]);
System.out.println(strline1[1]);
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if (selenium.isTextPresent("You have successfully Added the Reserve Type.")) break; } catch (Exception e) {}
Thread.sleep(1000);
}}
}

catch (Exception e) {
e.printStackTrace();
}

}
@AfterClass
public void tearDown() throws Exception {
selenium.stop();
}
}




and the file contain data like a,b

sanjeetravi
Regular Participant
Regular Participant

Posts : 27
Join date : 2012-07-10
Age : 26
Location : Delhi

Back to top Go down

Re: how to get data dynamically from Notepad file

Post by Sponsored content Today at 5:49 pm


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