How can I get in "gmail.com" website when input email after press next button id for selenium web driver? Does not exist. only exists <div class="ZFr60d CeoRYc"></div> this. How can I find ID of next button?
automation Gmail login using selenium webdriver in java in this link answer is id = identifierNext for next button. But how can I know it is ID?
You can also use xpath:
"//span[contains(text(), 'Next')]"
There is an id attribute for the Next button. You can use xpath like .//div[#role='button' and #id='identifierNext']. Hope it helps.
This is the html tag for next button by id:
driver.find_element_by_id("identifierNext").click()
Related
I am new to automation and stuck on click "continue" button,
<span class="iB button_inner">
Continue
I have tired with XPath, ccsSelector, linkText etc. my test fails with unable to locate an element.
Any help is appreciated.
Thanks.
To invoke click() on the element with text as Continue you can use the following solution:
driver.findElement(By.xpath("//span[#class='iB button_inner']/a[#data-tn-element='sheet-next-button' and contains(.,'Continue')]")).click();
driver.findElement(By.xpath("//*[contains(text(),'Continue']"))
Try This if continue button has text as "Continue."
Please post your error message in case you get any.
//a[contains(text(),'Continue')]
Try this for your object's xpath.
Trying to select Gender in Gmail registration page.. Clicking on Gender is opening a DIV with 3 options.. I was able to find the options using xpath and also capture the text or tagname.. but, click is not working
baseURL = "http://www.gmail.com";
driver.get(baseURL);
driver.findElement(By.id("link-signup")).click();
driver.findElement(By.id("Gender")).click();
Thread.sleep(1000);
driver.findElement(By.xpath("//div[#id='Gender']//div[#class='goog-menu goog-menu-vertical']//div[#id=':e']")).click();
The Gender in Gmail registration page is a dropdown. So, you need to wrap your WebElement into Select object and then select its option.
Following code may help you.
//Identify dropdown
Select gen= new Select(driver.findElement(By.id("Gender")));
//select its option.
gen.selectByVisibleText("Male");//provide value that you want to select here.
OR
gen.selectByIndex(1); // provide value's id here.
OR
gen.selectByValue("Ma");//provide value here.
I am trying to write some UI test cases for an SAP-webUI (web based) application. After login, it shows the dashboard ( Workcenter's ) screen.
Now the problem is, I am able to open the page, enter U/N, Pwd and login through Selenium. After i press the "Login" button the URL changes and the page got redirected/refreshed.
E.g. URL before login : https://a/b/c/d/e/f/g.htm?sap-client=001&sap-sessioncmd=open
E.g. URL after successful Login : https://a/b(bDsdfsdsf1lg==)/c/d/e/f/g.htm
After this im unable to perform any action or press any link in any part of the page. I tried with all the possible attributes ( css, xpath, id ). Webdriver was unable to find any element on the page. It shows the error "No element found" alone.
I am using java with Selenium Web Driver.
Please find the html structure of the webpage below
<html><body><div><div><iframe>#document<html><head></head><frameset><frameset><frame>#document<html><head></head><body><form><div><div><table><tbody><tr><td><div><ul><li><a id=abcdef></a></li></ul></div></td></tr></tbody></table></div></div></form></body></html></frame></frameset></frameset></html></iframe></div></div></body></html>
Actually i want to click a linkmenu "abcd", which is inside iframe and frame as shown in the below HTML code
<html><head></head><body><iframe name=a1><html><head></head><frameset><frameset name=fs1><frame name=f1><html><head></head><body><table><tbody><tr><td><ul><li><a id=abcdef>
I tried the below code as well.
driver.switchTo().frame("a1");
driver.findElement(By.id("abcd")).click();
OR
driver.findElement(By.xpath("//*[#id='abcd']")).click();
After using the above code, still im getting the error "No such element"
Kindly suggest
Regards,
Siva
Do it this way...
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[#name='a1']"))); // switching to iframe
followed by
driver.switchTo().frame("f1"); // switch to frame
and then your desired action...
driver.findElement(By.id("abcd")).click();
This is because of the iframe. You need to switch to it first:
driver.switchTo().frame(0);
driver.findElement(By.id("abcdef")).click();
where 0 is a frame index.
See doc on implicit wait here
I guess you should do a implicit wait until your chosen element is available
modify these code to suit your chosen element:
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("someid")));
I am writing selenium script for Gmail login and logout functionality. I am able to successfully login using below code.
//Open gmail
driver.get("http://www.gmail.com");
// Enter userd id
WebElement element = driver.findElement(By.id("Email"));
element.sendKeys("xyz#gmail.com");
//wait 5 secs for userid to be entered
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
//Enter Password
WebElement element1 = driver.findElement(By.id("Passwd"));
element1.sendKeys("Password");
//Submit button
element.submit();
But i could not write a script to logout. Could yu please provide me script for logout?
Thanks!
It is a very bad idea trying to automate Gmail. First of all, it is against Google's policy and when you sign up for Gmail, you accepted terms and conditions that you won't automate. Having said that there are many efficient ways to connect to your Gmail account. One of the approaches is to use IMAP client like IMAP4. Using this, you can connect to your Gmail, go through your inbox, delete messages,sign out etc. By doing this, you don't have to worry about automating UI portion. Also, Google changes its UI frequently just to stop people from automating it, so if you automate Gmail UI, then it might work today but it won't work after a couple of days.
Go through this link and you should be able to implement IMAP4 in your tests within few minutes:
http://mailsystem.codeplex.com/discussions/269058
Try the below code.
driver.findElement(By.className("gb_Ta")).click(); // To click the flyout menu
driver.findElement(By.className("gb_71")).click(); // To click the sign out button
Try the code below
driver.findElement(By.xpath("//*[#id='gb']/div[1]/div[1]/div/div[3]/div[1]/a")).click();
// click on actual logout button step 2
driver.findElement(By.id("gb_71")).click();
//closing the webdriver window after successful completion of the test
driver.close();
WebDriverWait wait=new WebDriverWait(driver,50);
WebElement logout=driver.findElement(By.cssSelector("span.gb_4.gbii"));
logout.click();
WebElement signout=driver.findElement(By.id("gb_71"));
signout.click();
After login to gmail, Try this code to logout:-
driver.findElement(By.xpath("//span[#class='gb_7 gbii']")).click(); driver.findElement(By.id("gb_71")).click();
use xpath
// Click on the image icon present in the top right navigational Bar
driver.findElement(By.xpath("//div[#class='gb_1 gb_3a gb_nc gb_e']/div/a")).click();
//Click on 'Logout' Button
driver.findElement(By.xpath("//*[#id='gb_71']")).click();
//Close the browser.
driver.close();
use cssSelector
//Click on the profile image present in the right top corner
driver.findElement(By.cssSelector("span.gb_3a.gbii")).click();
//Click on 'Sign Out' button
driver.findElement(By.id("gb_71")).click(); //Close the browser
window driver.close();
use cssselector:
driver.findElement(By.cssSelector("span.gb_8a.gbii")).click();
driver.findElement(By.id("gb_71")).click();
Try this code for sign out the gmail using the selenium webdriver. It's working for me
driver.findElement(By.cssSelector(".gb_b.gb_db.gb_R")).click();
Thread.sleep(5000);// Click on the image icon present in the top
right navigational Bar
driver.findElement(By.cssSelector(".gb_Fa.gb_Pe.gb_We.gb_wb")).click();
Thread.sleep(5000); //Signout button
I am trying to write a WebDriver test for the following site for learning purposes: http://www.mate1.com
On clicking the login link, I get a form to fill in my email id and password. As far as I understand, the form is shown in an iframe.
To enter the credentials, I tried to identify the number of iframes for that particular page (and found it as 7) and tried switching in to each iframe and search for the email field by XPath and the ID. However, I wasn't successful to find it. So how can this be done?
This is my code:
driver.get("http:www.mate1.com");
driver.findElement(By.xpath("//*[#id='header-container']/div/a")).click();
List <WebElement> frames = driver.findElements(By.tagName("iframe"));
System.out.println("Totalframes -> "+ frames.size());
driver.switchTo().frame(0);
driver.findElement(By.xpath("//[#id='email']")).sendKeys("xxxxxxxxx#rocketmail.com");
This is likely a good situation to use switchTo().frame(WebElement):
driver.switchTo().frame(findElement(By.cssSelector(".iframe-container>iframe")));
The login and password fields are not in an iframe, you can directly use the following code -
driver.findelement(By.id("email").sendKeys("xxxxxxxxx#rocketmail.com");
Try not to switch to any iframe and execute the above line, this will work.