-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElementVisibilityTest.java
More file actions
43 lines (38 loc) · 1.46 KB
/
Copy pathElementVisibilityTest.java
File metadata and controls
43 lines (38 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package basicselenium;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class ElementVisibilityTest {
public static void main(String [] args) throws InterruptedException
{
WebDriver driver=SetupClass.setupMethod("https://www.makemytrip.com/");
WebElement loginButton= driver.findElement(By.xpath("//*[@id='SW']/div[2]/div[1]/ul/li[6]/div/p"));
//Check Login button is displayed or not
if (loginButton.isDisplayed()== true)
{ //If displayed then click on login button.
loginButton.click();
WebElement submitButton=driver.findElement(By.xpath("//*[@id='SW']/div[2]/div[2]/div[2]/section/form/div[2]/button"));
if (submitButton.isEnabled()==false)
{
WebElement emailField=driver.findElement(By.id("username"));
emailField.clear();
//Check Continue Button
System.out.println(submitButton.isEnabled());
WebElement createAccount=driver.findElement(By.xpath("//*[@id='SW']/div[2]/div[2]/div[2]/section/div[3]/p/span[2]/a"));
//Click on create Account button
createAccount.click();
//check checkbox selected or not
System.out.println(driver.findElement(By.id("tnc")).isSelected());
driver.close();
}
}
else
{
//if login button is not displayed in first time then it try to sleep for 10 second and then try
// to check the login button.
Thread.sleep(10000);
if(loginButton.isDisplayed()!= true){driver.close();}
}
}
}