Selenium WebDriver Yahoo邮件注销错误 [英] Selenium WebDriver Yahoo mail sign out error

查看:77
本文介绍了Selenium WebDriver Yahoo邮件注销错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Selenium WebDriver的新手,我试图编写一个简单的脚本来登录yahoo电子邮件帐户,然后注销.我设法使登录部分正常工作,但无法使退出部分正常工作.我收到以下错误:

I'm new to Selenium WebDriver and I am trying to write a simple script to log into a yahoo email account and then logout. I have managed to get the login part work working but I haven't been able to get the sign out part to work. I get the following error:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate
element: {"method":"link text","selector":"Sign Out"}

到目前为止,我已经尝试了以下3件事: 1)

I have tried the following 3 things so far: 1)

driver.findElement(By.linkText("Sign Out")).click();

2)

driver.findElement(By.partialLinkText("Sign Out")).click();

3)

WebElement element2 = driver.findElement(By.linkText("Sign Out"));
element2.submit();

在每种情况下,我基本上都会得到相同的错误.我在下面粘贴了我的代码.任何帮助将不胜感激.

I essentially get the same error in each case. I have pasted my code below. Any help would be appreciated.

FirefoxDriver driver = new FirefoxDriver();
driver.get("https://login.yahoo.com/config/login_verify2?.intl=ca&.src=ym");
driver.manage().window().maximize();

WebElement element = driver.findElement(By.id("username"));
element.sendKeys("myid@yahoo.com");

driver.findElement(By.id("passwd")).sendKeys("mypassword"); 
element.submit();
Thread.sleep(40000);

driver.findElement(By.linkText("Sign Out")).click();    
Thread.sleep(40);

推荐答案

Mouse over
new Actions(driver).moveToElement(driver.findElement(By.id("yucs-profile_text"))).perform();

click Sign Out
driver.findElement(By.xpath("//a[contains(text(),'Sign Out')]")).click();

这篇关于Selenium WebDriver Yahoo邮件注销错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆