selenium-webdriver

How to locate the button element using Selenium through Python

落花浮王杯 提交于 2020-02-12 05:47:07
问题 I'm trying to find the element and click for the button "Not Now". I've tried with with css_selector, xpath, but I"m unable at all to find the proper way. HTML: 回答1: To locate and click() on the element with text as Not Now you can use the following Locator Strategy: Using xpath : driver.find_element_by_xpath("//button[text()='Not Now']").click() However, the element looks dynamic to me so you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the

How to open incognito/private window with Selenium WD for different browser types?

吃可爱长大的小学妹 提交于 2020-02-10 05:51:31
问题 I want to test my test cases in private window or incognito window . How to do the same in various browsers: firefox (prefered) chrome (prefered) IE safari opera How to achieve it? 回答1: Chrome: DesiredCapabilities capabilities = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments("incognito"); capabilities.setCapability(ChromeOptions.CAPABILITY, options); FireFox: FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference(

How to open incognito/private window with Selenium WD for different browser types?

≯℡__Kan透↙ 提交于 2020-02-10 05:50:49
问题 I want to test my test cases in private window or incognito window . How to do the same in various browsers: firefox (prefered) chrome (prefered) IE safari opera How to achieve it? 回答1: Chrome: DesiredCapabilities capabilities = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments("incognito"); capabilities.setCapability(ChromeOptions.CAPABILITY, options); FireFox: FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference(

How to open incognito/private window with Selenium WD for different browser types?

纵然是瞬间 提交于 2020-02-10 05:50:26
问题 I want to test my test cases in private window or incognito window . How to do the same in various browsers: firefox (prefered) chrome (prefered) IE safari opera How to achieve it? 回答1: Chrome: DesiredCapabilities capabilities = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments("incognito"); capabilities.setCapability(ChromeOptions.CAPABILITY, options); FireFox: FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference(

Clarification of the cause of mixing Implicit and Explicit waits of Selenium doc

左心房为你撑大大i 提交于 2020-02-09 01:08:08
问题 I was reading the SeleniumHQ documentation and came across the following statements. "WARNING: Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times. For example setting an implicit wait of 10s and an explicit wait of 15 seconds, could cause a timeout to occur after 20 seconds." For some reason, I cannot get this to make sense. The total timeout 20s is the main confusion point for me. Can anyone explain if I am missing something? EDIT My question is not about the

Going Headless in Selenium with Chrome using Python Executing, But Throwing Errors

寵の児 提交于 2020-02-08 02:29:06
问题 Based off the answer here I am trying to get Chrome to run headless in my script. The snippet of code below is inside of a function called login() that logs into our ERP system: if headless == True: options = Options() options.headless = True #Load webdriver driver = webdriver.Chrome(options=options, executable_path=r'C:/Users/d.kelly/Desktop/Python/chromedriver_win32/chromedriver.exe') if headless == False: driver = webdriver.Chrome('C:/Users/d.kelly/Desktop/Python/chromedriver_win32

Selenium switching to new Tab in IE

风流意气都作罢 提交于 2020-02-07 08:38:04
问题 I am using selenium Java. I need to open new tab and open URL in the newly opened tab. I am try to using getWindowHandles, its working fine in google chrome, but the same code is not working for Internet Explorer. Please suggest the proper solution for this. Here is the code I have used. WebDriver=new InternetExplorerDriver(); driver.get("https://google/com"); driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL+"t");// Open new tab driver.switchTo().window(driver.getWindowHandles

Element identified through find_element_by_xpath returns selenium.common.exceptions.ElementNotVisibleException: Message: element not visible

不羁岁月 提交于 2020-02-07 05:45:06
问题 I have problem with click button. This button can click if enemy is on play and can't click if enemy go out start I tried with this: try: element= driver.find_element_by_xpath("//button[@class='butwb']") if element.is_displayed(): print ("Element found") else: print ("Element not found") except NoSuchElementException: print("No element found") Result: Element not found If I add element.click() : selenium.common.exceptions.ElementNotVisibleException: Message: element not visible What I do

Selenium script hangs when popup window is opened and runs normally after 10 minutes

回眸只為那壹抹淺笑 提交于 2020-02-07 02:27:27
问题 I am having a weird issue that when I click to open the popup window then code freezes for exactly 10-12 minutes and then interacts normally with popup window. Following is complete code: System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+ "\\exe\\chromedriver.exe"); driver = new ChromeDriver(); driver.manage().window().maximize(); driver.manage().deleteAllCookies(); driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); driver.manage().timeouts()

How to wait until all network logs in generated?

丶灬走出姿态 提交于 2020-02-06 18:04:39
问题 I am using Selenium and Java for my tests. After a test completes, I download the HAR file which I later use for analyzing certain domains that exist in the page. I found that the HAR file that I download doesn't contain complete log of all the requests for that page. How do I wait until entire network traffic for a page completes before downloading the HAR file? I did try to use wait before downloading the HAR file but didn't work. Can you suggest some other ideas? WebDriverWait wait = new