I have been studying testing for 2 days and I am trying to make automatic test where a system have the below Two steps:
- Log in into Email
- 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.
-
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– Bhavani2018年02月07日 10:22:43 +00:00Commented Feb 7, 2018 at 10:22
4 Answers 4
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);
First of all, When I opened the link (http://gmail.com
) I found this 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"));
After clicking on
SIGN IN
, browser will open this page and you can run your remain code.
This should work for you...
wd.findElement(By.xpath("//div[text()='COMPOSE']")).click();
Thread.sleep(3000);
This should work for you...
wd.findElement(By.xpath("//div[@gh='cm']")).click();
Thread.sleep(3000);
Explore related questions
See similar questions with these tags.