khyati sehgal


{ City } ghaziabad
< Country > india
* Profession * automation qa
User No # 118526
Total Questions Posted # 0
Total Answers Posted # 4

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 19
Users Marked my Answers as Wrong # 6
Questions / { khyati sehgal }
Questions Answers Category Views Company eMail




Answers / { khyati sehgal }

Question { HCL, 16282 }

difference between Implicit Wait and Explicit Wait with syntax.?


Answer

EXPLICIT WAIT- Will stop the execution for the given mentioned time.
WebDriverWait wait = new WebDriverWait(driver, 10);

WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("someid")));

IMPLICIT WAIT- will be applicable toeach and every element on web

WebDriver driver = new FirefoxDriver();

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

driver.get("http://url_that_delays_loading");

WebElement myDynamicElement = driver.findElement(By.id("myDynamicElement"));

Is This Answer Correct ?    10 Yes 0 No

Question { HCL, 12220 }

what are the Dynamic elements in web Application?


Answer

Use these methods
Relative XPath with Starting Text
XPath: //button[starts-with(@id, 'tag-')]
Relative XPath with Text Contains
XPath: //input[contains(@class, '-test-')].
Element with Index
driver.findElements(By.xpath(“//*button”)).get(0).click();

Is This Answer Correct ?    7 Yes 0 No


Question { HCL, 9838 }

How do you handle Alerts and Pop Ups?


Answer

@Test
public void plainAlertTest() {
WebElement alertButton;
alertButton = driver.findElement(By.cssSelector("#alertexamples"));
alertButton.click();
assertThat(alertMessage, driver.switchTo().alert().getText());
// accept alert dialog to close
driver.switchTo().alert().accept();
}

@Test
public void confirmAlertTestOK() {
WebElement confirmAlertButton;
confirmAlertButton = driver.findElement(By
.cssSelector("#confirmexample"));
confirmAlertButton.click();
assertThat((driver.switchTo().alert().getText()),
is(confirmAlertMessage));
// accept alert dialog to close via 'OK'
driver.switchTo().alert().accept();
// verify page text is 'true'
String returnText = driver
.findElement(By.cssSelector("#confirmreturn")).getText();
assertThat(returnText, is("true"));
}

@Test
public void confirmAlertTestCancel() {
WebElement confirmAlertButton;
confirmAlertButton = driver.findElement(By
.cssSelector("#confirmexample"));
confirmAlertButton.click();
assertThat((driver.switchTo().alert().getText()),
is(confirmAlertMessage));
// accept alert dialog to close via 'OK'
driver.switchTo().alert().dismiss();
// verify page text is 'false'
String returnText = driver
.findElement(By.cssSelector("#confirmreturn")).getText();
assertThat(returnText, is("false"));
}

@Test
public void promptAlertTestOK() {
WebElement confirmAlertButton;
confirmAlertButton = driver.findElement(By
.cssSelector("#promptexample"));
confirmAlertButton.click();
// verify prompt alert text
assertThat((driver.switchTo().alert().getText()),
is(promptAlertMessage));
// change message
driver.switchTo().alert().sendKeys(promptText);
/*
* accept alert dialog to close via 'OK' how sendKeys help in closing OK
* button, why we simply dont click on click or press enter from
* keyboard.
*/
driver.switchTo().alert().accept();
// verify return text is (promptText)
String returnText = driver.findElement(By.cssSelector("#promptreturn"))
.getText();
assertThat(returnText, is(promptText));
}

@Test
public void promptAlertTestCancel() {
WebElement confirmAlertButton;
confirmAlertButton = driver.findElement(By
.cssSelector("#promptexample"));
confirmAlertButton.click();
// verify prompt alert text
assertThat((driver.switchTo().alert().getText()),
is(promptAlertMessage));
// change message
driver.switchTo().alert().sendKeys(promptText);
// REJECT alert dialog to close via 'Cancel'
driver.switchTo().alert().dismiss();
// verify return text is default "pret"
String returnText = driver.findElement(By.cssSelector("#promptreturn"))
.getText();
assertThat(returnText, is("pret"));
}

Is This Answer Correct ?    0 Yes 6 No

Question { HCL, 12163 }

What is the build Tool you have used in your project?


Answer

We have used maven as build tool, and git/svn/mercurial as version control tool.

Is This Answer Correct ?    2 Yes 0 No