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
Shirish
Posts : 1
Join date : 2014-07-30

Selenium not able to identify confirm dialog box while testing Empty Selenium not able to identify confirm dialog box while testing

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.
avatar
mail2prassad
Amateur
Amateur
Posts : 41
Join date : 2013-06-05

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

Mon Aug 04, 2014 11:14 pm
It looks like the alert is not windows standard alert box.
This may be a DIV.
avatar
anemuday
Active particpant
Active particpant
Posts : 11
Join date : 2012-10-11

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

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
avatar
deepender
Posts : 3
Join date : 2014-09-03

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

Wed Sep 03, 2014 8:06 pm
Try to search the element using class as a id
avatar
Paps_engineer
Active particpant
Active particpant
Posts : 10
Join date : 2014-07-24

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

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
Sponsored content

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

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