Can not take a selector(Xpath) of "Account settings button" and "find my iPhone" in iCloud

huangapple 未分类评论45阅读模式
英文:

Can not take a selector(Xpath) of "Account settings button" and "find my iPhone" in iCloud

问题

我需要在iCloud.com上点击“帐户设置”和“查找我的iPhone”按钮(不是同时点击)。但是我的选择器都不起作用。
页面上似乎没有框架,但Xpath表达式不匹配。

步骤:

  1. 登录iCloud帐户
  2. 查找“帐户设置”和“查找我的”按钮

这是我现在正在使用的:
对于“查找”按钮:

WebElement settings = wait.until(ExpectedConditions.
elementToBeClickable(By.xpath("//div[@class='user-name-with-chevron']")));
settings.click();

对于“帐户设置”:

WebElement settings = wait.until(ExpectedConditions.
elementToBeClickable(By.xpath("//div[@class='cw-button symbol-button link-button']")));
settings.click();

我感激任何帮助。如果我的问题很愚蠢,请原谅,我刚开始学习。

英文:

I need to click "Account settings" and "find my iPhone" buttons on iCloud.com (not at the same time). But none of my selectors working.
Looks like there are no frame on-page, but Xpaths not matching.

Steps:

  1. Sign in to iCloud account
  2. Find elements "Account setting" and "Find my" buttons

This is what I'm using now:
For Find button:

WebElement settings=wait.until(ExpectedConditions.
elementToBeClickable
(By.xpath("//div[@class='user-name-with-chevron']")));
settings.click();

For Account settings:

 WebElement settings = wait.until(ExpectedConditions.
 elementToBeClickable(By.xpath
 ("//div[@class='cw-button symbol-button link-button']")));
 settings.click(); 

I appreciate any help.
sorry if my questions stupid, just start to learn.

html page

答案1

得分: 0

我相信您可能在登录后错过了切换回默认内容。
我尝试了下面的代码,对我起作用:

    driver.findElement(By.id("sign-in")).click();
    driver.switchTo().defaultContent(); // 切换回默认内容
    driver.findElement(By.cssSelector("div.cw-button.symbol-button.link-button")).click(); // 点击帐户设置

在从 iframe 切换回默认内容后,我能够在页面上定位任何网页元素。
希望对您有所帮助 Can not take a selector(Xpath) of "Account settings button" and "find my iPhone" in iCloud

英文:

I believe you might have missed to switch back to default content after log in.
I tried below code and it worked for me :

driver.findElement(By.id("sign-in")).click();
driver.switchTo().defaultContent(); //switch to default content 
driver.findElement(By.cssSelector("div.cw-button.symbol-button.link-button")).click(); //click on Account settings

After switching from iframe to default content i was able to locate any webelement on page.
Hope this helps Can not take a selector(Xpath) of "Account settings button" and "find my iPhone" in iCloud

huangapple
  • 本文由 发表于 2020年4月6日 13:53:10
  • 转载请务必保留本文链接:https://java.coder-hub.com/61053683.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定