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.

Sagar007
1,3403 gold badges9 silver badges24 bronze badges
asked Feb 7, 2018 at 7:16
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. 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);
answered Feb 7, 2018 at 11:10
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.

answered Feb 7, 2018 at 11:42
0

This should work for you...

wd.findElement(By.xpath("//div[text()='COMPOSE']")).click();
Thread.sleep(3000);
answered Feb 7, 2018 at 11:21
0

This should work for you...

wd.findElement(By.xpath("//div[@gh='cm']")).click();
Thread.sleep(3000);
answered Feb 7, 2018 at 11:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.