Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org.openqa.selenium.NoSuchElementException: Unable to find element with xpath == //table[@id='groupActions']/tbody/tr/td/button[@title='GDelYesButton']
- driver.switchTo().alert();
- <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>
- 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();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement