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

Selenium not able to identify confirm dialog box while testing

View previous topic View next topic Go down

Selenium not able to identify confirm dialog box while testing

Post by Shirish on Wed Jul 30, 2014 4:17 pm

During sellenium testing I have a issue where i have a page in which i have a confirmation dialog box. Everything works fine until the time i have confirmation dialog box popped up. I have a delete button on which there is a confirmation popup for which i have to click on yes button.
when selenium tries to identify the confirmation dialog box i get an error message stating:

org.openqa.selenium.NoSuchElementException: Unable to find element with xpath == //table[@id='groupActions
']/tbody/tr/td/button[@title='GDelYesButton']


Also i have tried using

Code:
driver.switchTo().alert();

for which i get an error there is no alert active.



I have a issue where i have a page in which i have a confirmation dialog box. Everything works fine until the time i have confirmation dialog box popped up. I have a delete button on which there is a confirmation popup for which i have to click on yes button.
when selenium tries to identify the confirmation dialog box i get an error message stating:
Code:
org.openqa.selenium.NoSuchElementException: Unable to find element with xpath == //table[@id='groupActions']/tbody/tr/td/button[@title='GDelYesButton']
Also i have tried using
Code:
driver.switchTo().alert();
for which i get an  error there is no alert active.
UI Code for popup:
Code:
  <p:commandButton id="delete"
                     action="MBeanPath"
                     icon="ui-icon ui-icon-trash"
                     value="Delete"
                     title="GDeleteButton">
        <p:confirm header="Delete Record"
                   message="Are you sure about deleting this record?"
                   icon="ui-icon-alert"/>
    </p:commandButton>

<p:confirmDialog global="true" showEffect="fade">
    <p:commandButton title="GDelYesButton" value="Yes" styleClass="ui-confirmdialog-yes"/>
    <p:commandButton title="GDelNoButton" value="No" styleClass="ui-confirmdialog-no" />
</p:confirmDialog>
Please find the below code for my selenium testcase.
Code:
package test.selenium;

import java.awt.Robot;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;


public class DeleteTestNG {
    WebDriver driver;

    public Alert getCurrentAlert(){
        return driver.switchTo().alert();
    }

    public DeleteTestNG() {
    }

    /**
     * @throws java.lang.Exception
     */
    @BeforeTest
    public void setUp() throws Exception {
        // Use Internet Explorer and set driver;
        System.setProperty("webdriver.ie.driver","path");
        driver = new InternetExplorerDriver();

        // And now use this to visit URL
        driver.get("pageURL");
    }

    /**
     * @throws java.lang.Exception
     */
    @AfterTest
    public void tearDown() throws Exception {
        driver.close();
    }

    @Test
    public final void test() {
        final WebElement formElement = driver.findElement(By.id("searchForm"));
        final Select drpHaulierelement = new Select(formElement.findElement(By.id("data_input")));



        /*
         * List<WebElement> options = drpelement.getOptions(); for
         * (WebElement e : options) { System.out.println("Option " +
         * e.getText()); }
         */
        drpelement.selectByIndex(0);

        // Now submit the form. WebDriver will find the form for us from the
        // element
        final WebElement submit = driver.findElement(By.id("Submit"));
        submit.click();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            System.out.println("Caught");
        }

        // Test Search results
        final WebElement tableElement = driver.findElement(By.id("data_input_data"));
        System.out.println("Data Table child - " + tableElement.getText());
        final WebElement chkBoxElement1 = tableElement.findElement(By.xpath("//tbody[@id='data_input_data']/tr/td/div/div[2]"));
        System.out.println("chkBoxElement1 " + chkBoxElement1.getTagName()+ "--" + chkBoxElement1.getText());
        chkBoxElement1.click();

        final WebElement chkBoxElement2 = tableElement.findElement(By.xpath("//tbody[@id='data_input_data']/tr[2]/td/div/div[2]"));
        System.out.println("chkBoxElement2 " + chkBoxElement2.getTagName()+ "--" + chkBoxElement2.getText());
        chkBoxElement2.click();

        final WebElement gDeleteButton = tableElement.findElement(By.xpath("//table[@id='groupActions']/tbody/tr/td/button[@title='GDeleteButton']"));
        System.out.println("gDeleteButton " + gDeleteButton.getTagName() + "--"+ gDeleteButton.getText() + "--"+ gDeleteButton.getCssValue("title"));
        gDeleteButton.click();


        //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            System.out.println("Caught");
        }
        //driver.switchTo().alert();
        //driver.switchTo().activeElement();
        //driver.switchTo().alert();
        final WebElement yesButtonElement = tableElement.findElement(By.xpath("//table[@id='groupActions']/tbody/tr/td/button[@title='GDelYesButton']"));
        System.out.println("yesButtonElement " + yesButtonElement.getTagName()+ "--" + yesButtonElement.getText());
        yesButtonElement.submit();
    }

}
Any help much appreciated.

Shirish

Posts : 1
Join date : 2014-07-30

Back to top Go down

Re: Selenium not able to identify confirm dialog box while testing

Post by mail2prassad on Mon Aug 04, 2014 11:14 pm

It looks like the alert is not windows standard alert box.
This may be a DIV.

mail2prassad
Amateur
Amateur

Posts : 41
Join date : 2013-06-05

Back to top Go down

Re: Selenium not able to identify confirm dialog box while testing

Post by anemuday on Wed Aug 13, 2014 11:57 am

Hi,

I am hoping you are trying to accept the conformation dialog by clicking on Yes button.

If that is your case, use below syntax

Code:
Alert alert=driver.switchTo().alert();
// to get the text of alert message use alert.getText();
alert.accept(); //which clicks Yes or accepts this dialog
alert.dismiss(); //if you dont want to accept the terms.



I hope the above helps.

Thanks,
Uday

anemuday
Active particpant
Active particpant

Posts : 11
Join date : 2012-10-11

Back to top Go down

Re: Selenium not able to identify confirm dialog box while testing

Post by deepender on Wed Sep 03, 2014 8:06 pm

Try to search the element using class as a id

deepender

Posts : 3
Join date : 2014-09-03

Back to top Go down

Re: Selenium not able to identify confirm dialog box while testing

Post by Paps_engineer on Fri Oct 10, 2014 5:42 pm

I think you may use the Autoit .exe for this situation
to handle this alert try to use Autoit.exe script.

Thanks,
Papaiadasan.S,
Automation COE,
Indium Software India Limited.
(indiumsoft.com/core-qa-offerings/test-automation)

http://www.indiumsoft.com/core-qa-offerings/test-automation" title="Test Automation">Test Automation

Paps_engineer
Active particpant
Active particpant

Posts : 10
Join date : 2014-07-24

Back to top Go down

Re: Selenium not able to identify confirm dialog box while testing

Post by Sponsored content Today at 1:56 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