简体   繁体   中英

Cannot find element in the popup window with Selenium Webdriver

I'm using InternetExplorerDriver with Selenium Webdriver in Java.

I load a URL which simultaneously opens another window which has the login box. Using the method mentioned here

I could select the required window and also send keys into the focussed box.

popup.getKeyboard().sendKeys("yeuiryuiryweuiryeuiyterui");

However, the following:

popup.findElement(By.id("userName")).sendKeys("user")

is unable to find the element and throws an Element-not-found exception (something similar to this).

Where am I getting it wrong?

I will suggest you to try with xpath

String locator = "//*[@class='Class name of user name text box'and text()='if any']"

you can find the user name through firebug

List<WebElement> element = Driver.driver.findElements(By.xpath(locator));   

thn use click functions on web element , do the same on password and then click on login directly using Driver.selenium.click(xpath); and provide the xpath of login button in case id's are not present.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM