No reprint without the permission of the author!
Sometimes when you open a Web page, a dialog box prompts you to enter a user name and password, only after you enter the correct user name and password
To start browsing the web, but Webdriver cannot locate the elements in this dialog box, which means that the right button on the dialog doesn't respond.
I believe everyone has encountered this problem of the pit father, below provides a simple and effective method!
You can try this page https://www.engprod-charter.net/
Here are the pages to be processed today
ImportOrg.openqa.selenium.WebDriver;ImportOrg.openqa.selenium.chrome.ChromeDriver; Public classwindowDialog20161209 { Public Static voidMain (string[] args)throwsinterruptedexception {//TODO auto-generated Method StubSystem.setproperty ("Webdriver.chorme.driver", "c:\\training\\automation\\software\\drivers\\chromedriver_win32\ \chromedriver.exe "); Webdriver Driver=Newchromedriver ();//Driver.get ("http://test3.tcom.aws.toyota.com/tcom-apps/vapi-preview/console.html");//Thread.Sleep (the);//System.out.println ("User name and password required to open Web page");//driver.close ();Driver.get ("Http://toyota-oss:[email protected]/tcom-apps/vapi-preview/console.html"); Thread.Sleep (3000); Driver.switchto (). alert (). Accept (),------------the default selection of the pop-up window determines System.out.println ("The pop window has been processed."); }}
Here is the Python code
fromSeleniumImportWebdriverImport Time fromSelenium.webdriver.common.action_chainsImportActionchainsdriver=Webdriver. Chrome () Driver.get ("Http://toyota-oss:[email protected]/tcom-apps/vapi-preview/console.html")#alert = Driver.switch_to_alert () If it is the first time you open the link above, you need to alert.accept (), but after the second time, the cookie will no longer have a popup window.#alert.accept ()Driver.maximize_window () time.sleep (2)Print "go to Toyota home"
Webdriver processing of pop-up windows that cannot locate elements