How to add looping condition for selenium java code - java

I need to automate links in my website. I want to pass xpath values once in each iteration of loop. So that I can minimize my coding
public class Popup
{
private WebDriver driver;
private String baseUrl;
//private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
#Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://www.example.com/info.php";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
#Test
public void testPopup() throws Exception {
driver.findElement(By.xpath("//div[#id='info-list']/div[2]/div/div/div/div/a[2]/i")).click();
driver.findElement(By.xpath("//div[#id='info-list']/div[2]/div/div/div/div/a[3]/i")).click();
driver.findElement(By.xpath("//div[#id='info-list']/div[2]/div/div/div/div/a[4]/i")).click();
driver.findElement(By.xpath("//div[#id='info-list']/div[2]/div/div/div/div/a[5]/i")).click();

Can you try this?
for(int j=2; j<=5; j++) {
driver.findElement(By.xpath("//div[#id='info-list']/div[2]/div/div/div/div/a["+j+"]/i")).click();
}

Hi Sanchit Khera Try this one :
int i = 0;
//extract the link texts of each link element
for (WebElement e : linkElements)
{
linkTitles[i] = e.getText();
i++;
}
//Test each link
for (String t : linkTitles)
{
// Titles Click
driver.findElement(By.linkText(t)).click();

Related

Getting NPE NullPointerException in PageFactory (Selenium+Java)

I'm trying to implement Page Factory pattern for my testing framework, but I'm getting NPE while trying to reach or interact with elements. BTW, I'm using Spring Dependency Injection for sharing WebDriver instance among tests (instead of constructor), so I implemented PageFactory initElements() inside non-static block to be able to reach it.
BTW, without PageFactory (without #FindBy and with commented By items) it works perfect.
Here is my code of PO.class:
#Component
public class HomePage extends BasePage {
#Autowired
private DatabasesPage databasesPage;
#Autowired
private UserAccountsPage userAccountsPage;
public static Logger log = LogManager.getLogger(HomePage.class.getName());
private String themeLabelColorHex = "#235a81";
private Select themeList;
/* private By databasesHeaderButton = By.cssSelector("#topmenu > li:nth-child(1)"),
userAccountsHeaderButton = By.cssSelector("#topmenu > li:nth-child(4)"),
languagesDropdown = By.id("sel-lang"),
themeDropdown = By.name("set_theme"),
themeLabel = By.xpath("//*[#id='li_select_theme']//a");*/
#FindBy(how = How.CSS, css = "#topmenu > li:nth-child(1)") private WebElement databasesHeaderButton;
#FindBy(how = How.CSS, css = "#topmenu > li:nth-child(4)") private WebElement userAccountsHeaderButton;
#FindBy(how = How.ID, id = "sel-lang") private WebElement languagesDropdown;
#FindBy(how = How.NAME, name = "set_theme") private WebElement themeDropdown;
#FindBy(how = How.XPATH, xpath = "//*[#id='li_select_theme']//a") private WebElement themeLabel;
{
PageFactory.initElements(driver,this);
System.out.println("**************** THIS IS A NON-STATIC FIELD REACHED BY DEP INJ ****************");
}
public HomePage openUp() {
String propertiesPath = get(System.getProperty("user.dir"),
"src", "main", "java", "base", "configuration", "config.properties").normalize().toString();
try {
Properties properties = new Properties();
properties.load(new FileInputStream(propertiesPath));
String url = properties.getProperty("url");
driver.get(url);
}
catch ( IOException e) {
log.error("Properties file is not found");
log.error("\n " + ExceptionUtils.getStackTrace(e));
}
return this;
}
public DatabasesPage goToDatabasesPage() {
databasesHeaderButton.click();
return databasesPage;
}
public UserAccountsPage goToUserAccountsPage() {
userAccountsHeaderButton.click();
return userAccountsPage;
}
public HomePage changeLanguage(String langValue) {
try {
Select langList = new Select(languagesDropdown);
String currentLang = langList.getFirstSelectedOption().getAttribute("value");
if (langValue.equalsIgnoreCase(currentLang)) log.warn("Desired language is already selected!");
else langList.selectByValue(langValue);
}
catch (Exception e) {
log.error("\n" + ExceptionUtils.getStackTrace(e));
}
return this;
}
public HomePage changeTheme(String themeValue) {
try {
themeList = new Select(themeDropdown);
String currentTheme = themeList.getFirstSelectedOption().getAttribute("value");
if (themeValue.equalsIgnoreCase(currentTheme))
log.warn("Desired theme is already selected!");
else {
themeList.selectByValue(themeValue);
driver.navigate().refresh();
themeLabelColorHex = "#0000ff";
}
}
catch (Exception e) {
log.error("\n" + ExceptionUtils.getStackTrace(e));
}
return this;
}
public HomePage setDefaultTheme() {
themeList = new Select(themeDropdown);
themeList.selectByValue("pmahomme");
themeLabelColorHex = "#235a81";
return this;
}
public boolean isLanguageChanged() {
return true; // TO DO
}
public boolean isThemeChanged() {
String RGBColor = themeLabel.getCssValue("color"); // I'm getting NPE here somehow
String HexColor = Color.fromString(RGBColor).asHex();
return HexColor.equalsIgnoreCase(themeLabelColorHex);
}
}
Here is my Test method:
#Test
#Description("Change website theme")
public void changeWebsiteTheme() {
homePage.openUp().changeTheme("original");
assertThat(true).isEqualTo(homePage.isThemeChanged()); // and it fails here but it didn't perform previous step - changeTheme();
homePage.setDefaultTheme();
assertThat(true).isEqualTo(homePage.isThemeChanged());
}
enter code here
to initiate the PageFactory which is written in constructor, it has to be initiated by create the object of the class.
this helped me to achieve this.

Why is my assertion that the element contains a certain String failing even though it is there?

the assert at the end of the main method is failing, even though that string is contained within the element, at least according to the console write line i perform before the assert.
can anyone help me figure out why that assert is failing? I'm at my wit's end. Literally pulling my hair out.
And sorry if it's a mess, I am new to Java.
enum Item {
DRILL(100.00, "a0Gf40000005CctEAE", "Drill"), ///
WRENCH(15.00, "a0Gf40000005CcuEAE", "Wrench"), ///
HAMMER(10.00, "a0Gf40000005CcvEAE", "Hammer"); ///
private final double _price;
private final String _itemID;
private final String _itemDisplayName;
Item(double price, String itemID, String itemDisplayName){
this._price = price;
this._itemID = itemID;
this._itemDisplayName = itemDisplayName;
}
double getItemPrice() {
return _price;
}
String getItemID() {
return _itemID;
}
String getItemName() {
return _itemDisplayName;
}
}
public class TestCaseOne {
static WebDriver driver;
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
//System.setProperty("webdriver.gecko.driver", "geckodriver.exe");
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Item testItem = Item.WRENCH;
driver.get("http://test.com/WebOrderScreen");
AddItem(testItem);
ChangeItemQuantity(testItem, 3);
driver.findElement(By.xpath("//span[text()='Payment Information']")).click();
WebElement itemLink = driver.findElement(By.id("order-summary")).findElement(By.xpath(String.format(".//a[(#href='/%s')]", testItem.getItemID())));
WebElement itemParentRow = itemLink.findElement(By.xpath("../../../.."));
String text = itemParentRow.getText();
System.out.println(text);
Assert.assertTrue(itemParentRow.toString().contains(testItem.getItemName()));
}
public static void AddItem(Item item) {
//first find the link to the item we want
WebElement itemLink = driver.findElement(By.xpath(String.format("//a[(#href='/%s')]", item.getItemID())));
WebElement itemParentRow = itemLink.findElement(By.xpath("../../../.."));
itemParentRow.findElement(By.tagName("i")).click(); //now that we found the parent row of the item we want, click the button to add it
driver.findElement(By.id("shopping-cart")).findElement(By.xpath(String.format(".//a[(#href='/%s')]", item.getItemID())));
System.out.println("Item ENUM found in shopping cart: " + item);
///for debugging
/*
System.out.println(item.getItemID());
System.out.println(item.getItemPrice());
System.out.println(itemParentRow.getText());
*/
}
public static void ChangeItemQuantity(Item item, Integer quantity) {
WebElement itemLink = driver.findElement(By.id("shopping-cart")).findElement(By.xpath(String.format(".//a[(#href='/%s')]", item.getItemID())));
WebElement itemParentRow = itemLink.findElement(By.xpath("../../../../.."));
//System.out.println("Old item count: " + itemParentRow.findElement((By.xpath(".//input[#inputmode='numeric']"))).getAttribute("value"));
itemParentRow.findElement((By.xpath(".//input[#inputmode='numeric']"))).clear();
itemParentRow.findElement((By.xpath(".//input[#inputmode='numeric']"))).sendKeys(quantity.toString());
//System.out.println("New item count: " + itemParentRow.findElement((By.xpath(".//input[#inputmode='numeric']"))).getAttribute("value"));
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[#id='shopping-cart']//td[#class='nx-summary']")));
}
}
In the assertion you are calling toString() on WebElement, which returns something like:
[[[[[[ChromeDriver: chrome on LINUX (084b45f48be31410009e34b87903f54a)] -> id: order-summary]] -> xpath: .//a[(#href='/a0Gf40000005CcuEAE')]]] -> xpath: ../../../..]
Just like Andy indicated, you should use itemParentRow.getText().

Why webdriver continuously open for each operation?

I am beginner in Selenium, there are two separate .xls file file one for GmailTestSuite.xls and other for objectrepository.xls.
I have created MainClass, in it I have written a code which read both .xls file, also I've open the driver in it and perform operation. But problem is that it continuously open new driver but don't perform any operation.
Please suggest and let me know where I'm going wrong.
public class MainClass {
static Properties properties= null;
public static void main(String[] args) throws IOException, BiffException{
// TODO Auto-generated method stub
ReadPropertyFile readConfigFile= new ReadPropertyFile();
properties= readConfigFile.loadPropertiess();
ExcelHandler testSuite= new ExcelHandler("D:\\GmailTestSuite.xls", "Suite");
testSuite.columnData();
int rowCount= testSuite.rowCount();
System.out.println("Total Rows="+rowCount);
for(int i=1;i<rowCount;i++)
{
String executable= testSuite.readCell(testSuite.getCell("Executable"), i);
System.out.println("Executable="+executable);
if(executable.equalsIgnoreCase("y")){
// exe. the process
String scenarioName= testSuite.readCell(testSuite.getCell("TestScenario"), i);
System.out.println("Scenario Name="+scenarioName);
ExcelHandler testScenarios= new ExcelHandler("D:\\GmailTestSuite.xls", scenarioName);
int rowWorkBook1= testScenarios.rowCount();
for(int j=1; j<rowWorkBook1;j++){
String framWork= testScenarios.readCell(testScenarios.getCell("FrameworkName"), j);
String operation = testScenarios.readCell(testScenarios.getCell("Operation"), j); //SendKey
String value= testScenarios.readCell(testScenarios.getCell("Value"), j);
System.out.println("FRMName="+framWork+",Operation="+operation+",Value="+value);
ExcelHandler objectRepository= new ExcelHandler("D:\\objectrepository.xls", "OR");
objectRepository.columnData();
int rowCount1= testSuite.rowCount();
System.out.println("Total Rows="+rowCount1);
for(int k=1;k<rowCount;k++){
String frameWorkName= objectRepository.readCell(objectRepository.getCell("Executable"), k);
String ObjectName= objectRepository.readCell(testScenarios.getCell("ObjectName"), k);
String Locator = objectRepository.readCell(testScenarios.getCell("Locator"), k); //SendKey
System.out.println("FrameWorkName="+frameWorkName+",ObjectName="+ObjectName+",Locator="+Locator);
//ExcelHandler executeOperation = new ExcelHandler(ObjectName, operation, value);
File file= new File("D:\\softs\\FF installed\\FF18\\firefox.exe");
FirefoxBinary fb = new FirefoxBinary(file);
WebDriver driver = new FirefoxDriver(fb,new FirefoxProfile());
driver.get("https://www.gmail.com");
WebElement we = driver.findElement(By.id("Email"));
if(operation.equalsIgnoreCase("SendKey"))
{
we.sendKeys("abc#gmail.com");
we.sendKeys("si#2013");
}
if(operation.equalsIgnoreCase("Click"))
we.click();
}
}
}
}
}
A couple of guide lines for better formed code:
Break your code into methods that only do one thing each. That way it's easier to manage and nicely compartmentalized, plus you don't enter into indentation hell with such embedded loop and if structures as the one you have over here.
Use class variables for things like the WebDriver instance, so you can initialize it once and keep calling on it later.
Don't hard code text into the application, use constants. Then you only need to define the text once and can refer to it multiple times. Makes the code much easier to maintain and change, when you don't have to search and replace through entire class, after some details (like a file path) change.
Also, I'm guessing you meant to do the following:
loop the rows in objectRepository in the k-loop, instead of looping the rows in the testSuite again.
get cells from objectRepository rather than from testScenarios when reading the cells from objectRepository
Example:
public class MainClass {
private static final String BROWSER_PATH = "D:\\softs\\FF installed\\FF18\\firefox.exe";
private static final String TEST_SUITE_PATH = "D:\\GmailTestSuite.xls";
private static final String OBJECT_REPOSITORY_PATH = "D:\\objectrepository.xls";
private static final String ADDRESS_TO_TEST = "https://www.gmail.com";
private static final By EMAIL_INPUT = By.id("Email");
// other constants
private WebDriver driver;
private Properties properties;
public MainClass() {
File file = new File(BROWSER_PATH);
FirefoxBinary fb = new FirefoxBinary(file);
driver = new FirefoxDriver(fb, new FirefoxProfile());
driver.get(ADDRESS_TO_TEST);
}
public static void main(String[] args) throws IOException, BiffException {
MainClass main = new MainClass();
main.handleTestSuite();
}
private void handleTestSuite() {
ReadPropertyFile readConfigFile = new ReadPropertyFile();
properties = readConfigFile.loadPropertiess();
ExcelHandler testSuite = new ExcelHandler(TEST_SUITE_PATH, "Suite");
testSuite.columnData();
int rowCount = testSuite.rowCount();
System.out.println("Total Rows=" + rowCount);
for (int i = 1; i < rowCount; i++) {
String executable = testSuite.readCell(testSuite.getCell("Executable"), i);
System.out.println("Executable=" + executable);
if (executable.equalsIgnoreCase("y")) {
// exe. the process
String scenarioName = testSuite.readCell(testSuite.getCell("TestScenario"), i);
System.out.println("Scenario Name=" + scenarioName);
handleScenario(scenarioName);
}
}
}
private void handleScenario(String scenarioName) {
ExcelHandler testScenarios = new ExcelHandler(TEST_SUITE_PATH, scenarioName);
int rowWorkBook1 = testScenarios.rowCount();
for (int j = 1; j < rowWorkBook1; j++) {
String framWork = testScenarios.readCell(testScenarios.getCell("FrameworkName"), j);
String operation = testScenarios.readCell(testScenarios.getCell("Operation"), j); // SendKey
String value = testScenarios.readCell(testScenarios.getCell("Value"), j);
System.out.println("FRMName=" + framWork + ",Operation=" + operation +
",Value=" + value);
handleObjects(operation);
}
}
private void handleObjects(String operation) {
ExcelHandler objectRepository = new ExcelHandler(OBJECT_REPOSITORY_PATH, "OR");
objectRepository.columnData();
int rowCount = objectRepository.rowCount();
System.out.println("Total Rows=" + rowCount);
for (int k = 1; k < rowCount; k++) {
String frameWorkName = objectRepository.readCell(objectRepository.getCell("Executable"), k);
String ObjectName = objectRepository.readCell(objectRepository.getCell("ObjectName"), k);
String Locator = objectRepository.readCell(objectRepository.getCell("Locator"), k); // SendKey
System.out.println("FrameWorkName=" + frameWorkName +
",ObjectName=" + ObjectName + ",Locator=" + Locator);
operateWebDriver(operation);
}
}
private void operateWebDriver(String operation) {
WebElement we = driver.findElement(EMAIL_INPUT);
if (operation.equalsIgnoreCase("SendKey")) {
we.sendKeys("abc#gmail.com");
we.sendKeys("si#2013");
} else if (operation.equalsIgnoreCase("Click")) {
we.click();
}
}
}
If ExcelHandler is your own implementation, you really should move the getCell(String s) method inside the readCell() method to change the call pattern of handler.readCell(handler.getCell("foo"), i) into handler.readCell("foo", i). If it's a library you're using, you can always make a helper method:
private static String readCell(ExcelHandler handler, String cellName, int row) {
return handler.readCell(handler.getCell(cellName), row);
}
EDIT
Since you're having problems with getting WebDriver to work, simplify things and take everything else out of the equation for now. In order to do that let's ignore all the reading data from .xls files. This is where having different methods for different things makes your design shine, since you can just comment one method call instead of having to comment out 50 lines of code from your one mega method.
Changed the above code a bit (just commented call to the other methods out and omitted them from the snippet, moved the line opening the correct page into constructor and rewrote the operateWebDriver() method a bit):
public class MainClass {
private static final String ADDRESS_TO_TEST = "https://www.gmail.com";
private static final By EMAIL_INPUT = By.id("Email");
private static final By PASSWORD_INPUT = By.id("Passwd");
private static final By SIGN_IN_BUTTON = By.id("signIn");
private static final String EMAIL = "test#abc.com";
private static final String PASSWORD = "test123";
private WebDriver driver;
public MainClass() {
File file = new File(BROWSER_PATH);
FirefoxBinary fb = new FirefoxBinary(file);
driver = new FirefoxDriver(fb, new FirefoxProfile());
driver.get(ADDRESS_TO_TEST);
}
public static void main(String[] args) throws IOException, BiffException {
MainClass main = new MainClass();
//main.handleTestSuite();
main.operateWebDriver("Click", EMAIL_INPUT);
main.operateWebDriver("SendKey", EMAIL_INPUT, EMAIL);
main.operateWebDriver("Click", PASSWORD_INPUT);
main.operateWebDriver("SendKey", PASSWORD_INPUT, PASSWORD);
main.operateWebDriver("Click", SIGN_IN_BUTTON);
}
private void operateWebDriver(String operation, By element) {
operateWebDriver(operation, element, null);
}
private void operateWebDriver(String operation, By element, String keys) {
WebElement we = driver.findElement(element);
if (operation.equalsIgnoreCase("SendKey")) {
we.sendKeys(keys);
} else if (operation.equalsIgnoreCase("Click")) {
we.click();
}
}
}
Then once you get WebDriver working, you can start reading the data from the files and using it to operate WebDriver.
#user2092132- You require to make changes on two places in your code
1: Insert new line after line- System.out.println("Total Rows="+rowCount);
WebDriver driver = null;
2:Change line from: WebDriver driver = new FirefoxDriver(fb,new FirefoxProfile());
To: driver = new FirefoxDriver(fb,new FirefoxProfile());
Above two changes should resolve initiating new instacne of FF each time.

How to run multiple tests in one instance of driver

I have the following code, I am extracting data from excel sheet and filling web form. Its a registration form and its registering two users. But once the second test runs, it starts another instance of driver. May I know how to do it in one instance.
#RunWith(Parameterized.class)
public class form {
private static WebDriver driver;
private String first;
private String last;
private String phone;
private String country;
private String about;
public form(String first, String last, String phone, String country, String about)
{
this.first = first;
this.last = last;
this.phone = phone;
this.country = country;
this.about = about;
}
#Before
public void before()
{
driver = new FirefoxDriver();
driver.manage().window().maximize();
}
#Parameters
public static Collection<Object[]> supplydata() throws IOException
{
File excel = new File("C:\\Users\\Master\\Desktop\\search_query_log.xls");
FileInputStream fis = new FileInputStream(excel);
HSSFWorkbook wb = new HSSFWorkbook(fis);
HSSFSheet ws = wb.getSheet("Sheet1");
int rowNum = ws.getLastRowNum() + 1;
int colNum = ws.getRow(0).getLastCellNum();
Object[][] data = new Object[rowNum][colNum];
for (int i=0; i < rowNum ; i++)
{
HSSFRow row = ws.getRow(i);
for(int j=0; j < colNum ; j++)
{
HSSFCell cell = row.getCell((short) j);
if(cell.getCellType()==cell.CELL_TYPE_STRING)
{
data[i][j]=cell.getStringCellValue();
}
else if(cell.getCellType()==cell.CELL_TYPE_NUMERIC)
{
data[i][j]=String.valueOf(cell.getNumericCellValue());
}
}
}
return Arrays.asList(data);
}
#Test
public void testcase() throws IOException, InterruptedException
{
driver.get("http://www.samplereg.com");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.id("fname")).sendKeys(first);
driver.findElement(By.name("lastname")).sendKeys(last);
driver.findElement(By.name("phonenumber")).sendKeys(phone);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
WebElement gender = driver.findElement(By.xpath("//input[#value='Male']"));
if (!gender.isSelected())
gender.click();
assertTrue(gender.isSelected());
driver.findElement(By.name("country")).sendKeys(country);
driver.findElement(By.name("desc")).sendKeys(about);
Select industry = new Select(driver.findElement(By.name("industry")));
assertFalse(industry.isMultiple());
assertEquals(6, industry.getOptions().size());
List<String> exp_options = Arrays.asList(new String[]{"Select Industry", "IT", "BPO","Sales","Development","Other"});
List<String> act_options = new ArrayList<String>();
for(WebElement option : industry.getOptions())
act_options.add(option.getText());
assertArrayEquals(exp_options.toArray(),act_options.toArray());
assertEquals("Select Industry", industry.getFirstSelectedOption().getText());
industry.selectByVisibleText("BPO");
assertEquals("BPO", industry.getFirstSelectedOption().getText());
Select education = new Select(driver.findElement(By.name("educationList")));
assertFalse(education.isMultiple());
assertEquals(4, education.getOptions().size());
List<String> exp_options1 = Arrays.asList(new String[]{"Select Education", "Post Graduate", "Graduate", "Under Graduate"});
List<String> act_options1 = new ArrayList<String>();
for(WebElement option1 : education.getOptions())
act_options1.add(option1.getText());
assertArrayEquals(exp_options1.toArray(),act_options1.toArray());
assertEquals("Select Education", education.getFirstSelectedOption().getText());
education.selectByVisibleText("Graduate");
assertEquals("Graduate", education.getFirstSelectedOption().getText());
WebElement hobby = driver.findElement(By.xpath("//input[#value='Listening Music']"));
if (!hobby.isSelected())
hobby.click();
assertTrue(hobby.isSelected());
driver.findElement(By.cssSelector("input[type=file]")).sendKeys("C:\\Users\\Master\\Desktop\\image.jpg");
driver.findElement(By.cssSelector("input[type=submit]")).click();
}
#After
public void after()
{
//driver.quit();
}
}
How about trying the below. Hope my understanding is correct.
#BeforeClass
public static void setUpClass() {
driver = new FirefoxDriver();
driver.manage().window().maximize();
Alert javascriptAlert = driver.switchTo().alert();
System.out.println(javascriptAlert.getText()); // Get text on alert box
javascriptAlert.accept(); // Chose whether to accept or cancel based on need
}
You can remove the #before method.

In Flash page Select box (combobox) is not working using Webdriver

I have done some sample code to select a combobox using webdriver in a Flash page but Select(...) and type(....) methods are not working but click(....) method works fine.
Please help to resolve this.
Type-1: Below methods are not working.
public void type(String locator, String value)
{
((JavascriptExecutor) webDriver).executeScript("document.getElementById('" + flashObjectId + "').fp_type({" + locator +", 'text':'"+ value +"'})");
}
public void select(String locator, String value)
{
((JavascriptExecutor) webDriver).executeScript("document.getElementById('" + flashObjectId + "').fp_select({" + locator +", 'label':'"+ value +"'})");
}
Its working fine in below click(....) method.
public String click(final String objectId, final String optionalButtonLabel)
{
return call("doFlexClick", objectId, optionalButtonLabel);
}
private String call(final String functionName, final String... args)
{
final Object result =
((JavascriptExecutor)webDriver).executeScript(
makeJsFunction(functionName, args),
new Object[0]);
return result != null ? result.toString() : null;
}
private String makeJsFunction(final String functionName, final String... args)
{
final StringBuffer functionArgs = new StringBuffer();
if (args.length > 0)
{
for (int i = 0; i < args.length; i++)
{
if (i > 0)
{
functionArgs.append(",");
}
functionArgs.append(String.format("'%1$s'", args[i]));
System.out.println("functionArgs: "+functionArgs);
}
}
return String.format(
"return document.%1$s.%2$s(%3$s);",
flashObjectId,
functionName,
functionArgs);
}
Please help to fix this in select box and tyep operation using webdriver in Flash.
Thanks in Advance,
Gopal
Watir-Webdriver does not support flash pages.

Categories