I'm Facing a problem for the signout session in gmail.The thing is
that i have used Xpath for the signout and tool is unable to identify
the xpath during the execution.
Could any one help me in solving this issue and please look at the
code below for reference
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.android.AndroidDriver;
import com.thoughtworks.selenium.Selenium;
public class mobile {
public static void main(String[] args) throws Exception
{
// TODO Auto-generated method stub
String baseUrl = "http://gmail.com";
AndroidDriver driver = new AndroidDriver();
Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);
selenium.open("http://gmail.com");
Thread.sleep(1000);
driver.findElement(By.id("Email")).sendKeys("xxxxx");
Thread.sleep(1000);
driver.findElement(By.id("Passwd")).sendKeys("12345");
Thread.sleep(8000);
driver.findElement(By.name("signIn")).click();
Thread.sleep(80000);
driver.findElement(By.xpath("//div[@id='tltbt']/div/div/
div")).click();
Here from the above the tool is unable to find the Xpath showing the
error as
Exception in thread "main" org.openqa.selenium.NoSuchElementException:
Could not find element with xpath: //div[@id='tltbt']/div/div/div
For documentation on this error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: os.name: 'Linux', os.arch: 'armv5tejl', os.version:
'2.6.29-gb0d93fb-dirty', java.version: '0'
Hello All,
import com.thoughtworks.selenium.Selenium;
public class mobile {
--
You received this message because you are subscribed to the Google Groups
"Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to
selenium-user...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/selenium-users?hl=en.
--
This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
If you have received this email in error please notify postm...@ardescosolutions.com
Exception in thread "main" org.openqa.selenium.WebDriverException: Error: {"message":"Unable to locate an element with the xpath expression \/\/*contains[@id='titb']\/div\/div\/div because of the following error:\nError: INVALID_EXPRESSION_ERR: DOM XPath Exception 51"}
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: os.name: 'Linux', os.arch: 'armv5tejl', os.version: '2.6.29-gb0d93fb-dirty', java.version: '0'
Driver info: driver.version: EventFiringWebDriver; duration or timeout: 998 milliseconds.
Look ath the HTML source for Gmail and see if the element you are looking for is inside either an iFrame or a Frame. If it is you need to switch to the frame before you will be able to access the element that you are trying to click on. The WebDriver way to switch frames is:
WebElement myFrame = driver.findElement(By.xpath("//iframe"));
driver.switchTo().frame(myFrame);
Yes it is, you need to look at the page source for the default page:
//iframe[@id='canvas_frame']
Gmail is not a good place to start leaning selenium it has some very complicated and convoluted HTML and is very hard to keep track of. You need a very good understanding of HTML and locator strategies to be able to automate it.
I would suggest starting on something a little less complex.