[英]Element On Pop-Up Window Not Found
I can't seem to find the elements of a log-in mask on mediafire . 我似乎在mediafire上找不到登录掩码的元素。 Waiting for an element to be visible using the following code 使用以下代码等待元素可见
public WebElement waitForElement(By identifier)
{
return new WebDriverWait(driver, 10).until(ExpectedConditions
.visibilityOfElementLocated(identifier));
}
times out even though the element is there after about 1 second. 即使该元素在大约1秒后仍存在,也会超时。
I tried to locate the e-mail field using By.xPath("//*[@id=\\"widget_login_email\\"]")
and By.cssSelector("#widget_login_email")
but neither worked. 我尝试使用By.xPath("//*[@id=\\"widget_login_email\\"]")
和By.cssSelector("#widget_login_email")
来查找电子邮件字段,但By.cssSelector("#widget_login_email")
。
driver.getWindowHandles().size()
returns 1
so there's no other window which needs to be switched to. driver.getWindowHandles().size()
返回1
因此没有其他窗口需要切换。
This is the html: 这是html:
<form id="form_login1" method="post" action="/dynamic/client_login/mediafire.php" target="widgetwork"> <label class="ieLabel">Email address</label> <input type="email" pattern="^(.)+@[A-Za-z0-9]([A-Za-z0-9\.-]*[A-Za-z0-9])?\.[A-Za-z]{1,13}$" name="login_email" id="widget_login_email" placeholder="Email address"> <label class="ieLabel">Password</label> <input type="password" name="login_pass" id="widget_login_pass" placeholder="Password" maxlength="30"> <div id="login_remember_wrap"><input type="checkbox" name="login_remember" id="login_remember" checked="checked"><label for="login_remember">Keep me logged in</label></div> <a class="forgotPassword" href="/lost_password.php" target="_blank">Forgot password?</a> <button type="submit" class="gbtnTertiary" onclick="">Log in</button> </form>
Please help me to find those elements using WebDriver. 请帮助我使用WebDriver查找那些元素。
Note: I'm using Selenium and ChromeDriver . 注意:我正在使用Selenium和ChromeDriver 。
The problem, I assume, is you are getting a NoSuchElementException
. 我认为问题是您收到了NoSuchElementException
。
The reason for your issue is the element is contained within an iframe
. 问题的原因是该元素包含在iframe
。 Specifically, this one: 具体来说,这一个:
<iframe name="modal_msg_iframe" id="modal_msg_iframe" src="/templates/login_signup/login_signup.php?dc=loginPath&_svefr=2390" scrolling="no" frameborder="0" allowtransparency="true" style="width: 686px; height: 600px;"></iframe>
You will need to switch to that iframe
before you can access the element. 您需要先切换到该iframe
然后才能访问该元素。
driver.switchTo().frame("modal_msg_iframe");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.