1

I have been studying testing for 2 days and I am trying to make automatic test where a system have the below Two steps:

  1. Log in into Email
  2. Send a email

I completed first step and I have problem with second. After login, the system will click button "Create Message" but it doesn't get clicked. Window with new message can't display and test is failed.

I have tried in many ways. Please look at my code and screens below in links:

Code: https://pastebin.com/QELY8Cje

Screen: https://i.sstatic.net/R8muR.jpg

@edit

Password in code is wrong so don't try use it.

1
  • Can you try this two things: 1. Add wait for the element visible and 2. Try with this locator "//*[@id=":gg"]/div/div" for compose button.
    – Bhavani
    Commented Feb 7, 2018 at 10:22

4 Answers 4

1

Try to set an implicit wait. 90% of the times the problem is a synchronization issue:

WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
1

First of all, When I opened the link (http://gmail.com) I found this page.

Google Home Page

Before performing any actions you need to click SIGN IN button.

Element :

LinkText = Sign In

OR

LinkText = SIGN IN

OR

css = a[class='gmail-nav__nav-link gmail-nav__nav-link__sign-in']

OR

xpath = //a[@class='gmail-nav__nav-link gmail-nav__nav-link__sign-in']


Code should be like this from line num 38 :

 wd.get(url);
 wd.findElement(By.xpath("//a[@class='gmail-nav__nav-link gmail-nav__nav-link__sign-in']")).click();
 Thread.sleep(2000); // remove this after your code get run properly
 WebElement loginName = wd.findElement(By.name("identifier"));

Sign In Page

After clicking on SIGN IN, browser will open this page and you can run your remain code.

0

This should work for you...

wd.findElement(By.xpath("//div[text()='COMPOSE']")).click();
Thread.sleep(3000);
0

This should work for you...

wd.findElement(By.xpath("//div[@gh='cm']")).click();
Thread.sleep(3000);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.