webdriverwait

Is it possible to switch to an element in a frame without using driver.switchTo().frame(“frameName”) in Selenium Webdriver Java?

余生颓废 提交于 2019-11-26 18:01:33
I have a multiple nested frames and I need to access the elements under these. As these frames are dynamic I am not able to access these elements. Is it possible for me to access the elements without using driver.switchTo().frame() ? Like using the xpath directly or jquery, javascript or anything? Any suggestions are welcome In simple words, No , it wouldn't be possible to access the elements without switching into the intended <iframe> i.e. without using driver.switchTo().frame() To switch to the intended frame you have to use either of the following : Switch through Frame Name : driver

org.openqa.selenium.ElementNotVisibleException: Element is not currently visible while clicking a checkbox through SeleniumWebDriver and Java

半腔热情 提交于 2019-11-26 14:57:41
问题 I have to select a checkbox that is contained in the following HTML snippet. The checkbox is contained in an input tag <div formarrayname="entityTypes" fxlayout="" fxlayoutgap="10px" class="ng-untouched ng-pristine ng-valid ng-star-inserted" style="flex-direction: row; box-sizing: border-box; display: flex;"> <div class="form-row ng-untouched ng-pristine ng-valid" fxlayout="row" fxlayoutgap="10px" style="flex-direction: row; box-sizing: border-box; display: flex;"> <app-checkbox

How to get rid of the hardcoded sleep()?

非 Y 不嫁゛ 提交于 2019-11-26 14:54:57
问题 def textfield(boxid,textadded): project = driver.find_element_by_id(boxid) project.send_keys(textadded) sleep(3) def dropdown(dropdownid, dropdownvalue): select = Select(driver.find_element_by_id(dropdownid)) select.select_by_visible_text(dropdownvalue) sleep(5) These 2 functions are functional however i'm using sleep() which is a bad practice since some my drop-downs and text fields will take longer than others to fill so i have to put the longest sleep value not to get errors, how can i fix

How to sleep webdriver in python for milliseconds

依然范特西╮ 提交于 2019-11-26 14:47:16
I am using the time library in my script: import time time.sleep(1) It can sleep my webdriver for 1 second but I need to sleep it for 250 milliseconds. To suspend the execution of the webdriver for milliseconds you can pass number of seconds or floating point number of seconds as follows: import time time.sleep(1) #sleep for 1 sec time.sleep(0.25) #sleep for 250 milliseconds However while using Selenium and WebDriver for Automation using time.sleep(secs) without any specific condition to achieve defeats the purpose of Automation and should be avoided at any cost. As per the documentation: time

StaleElementException when iterating with Python

穿精又带淫゛_ 提交于 2019-11-26 12:33:23
I'm trying to create a basic web scraper for Amazon results. As I'm iterating through results, I sometimes get to page 5 (sometimes only page 2) of the results and then a StaleElementException is thrown. When I look at the browser after the exception is thrown, I can see that the driver/page did not scroll down to where the page numbers are (bottom bar). My code: driver.get('https://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=sonicare+toothbrush') for page in range(1,last_page_number +1): driver.implicitly_wait(10) bottom_bar = driver.find_element_by_class_name(

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable with Selenium and Python

北慕城南 提交于 2019-11-26 11:39:28
问题 I am currently working on a project which fills a form automatically. And the next button appears when the form is filled, that\'s why it gives me an error. I have tried: WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,\"//input[@type=\'button\' and @class=\'button\']\"))) Next = driver.find_element_by_xpath(\"//input[@type=\'button\' and @class=\'button\']\") Next.click() HTML: <span class=\"btn\"> <input type=\"button\" value=\"Next\" class=\"button\" payoneer=\"Button\

WebDriverWait not working as expected

浪子不回头ぞ 提交于 2019-11-26 10:04:47
问题 I am working with selenium to scrape some data. There is button on the page that I am clicking say \"custom_cols\". This button opens up a window for me where I can select my columns. This new window sometimes takes some time to open (around 5 seconds). So to handle this I have used WebDriverWait with delay as 20 seconds. But some times it fails to select find elements on new window, even if the element is visible. This happens only once in ten times for rest of time it works properly. I have

Message: Element <option> could not be scrolled into view while trying to click on an option within a dropdown menu through Selenium

感情迁移 提交于 2019-11-26 08:38:34
问题 I am trying to select a drop down menu and choose an option. I am using the latest version of Selenium, the latest version of Firefox, the latest version of geckodriver, and the latest version of Python. Here is my issue: When I try to choose an option, it gives me the following error: selenium.common.exceptions.ElementNotInteractableException: Message: Element <option> could not be scrolled into view. I have tried various ways to circumnavigate this issue, but none seem to work. Here are

getWindowHandles() not working in firefox 58.The focus remains on parent tab and does not transfer to next tab

耗尽温柔 提交于 2019-11-26 08:38:28
问题 I am starting to learn how to handle multiple tabs in a browser using Selenium with Java. looks like my code below is not working. import java.util.ArrayList; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class HandlingWindows { public static void main(String[] args) throws InterruptedException { WebDriver driver= new FirefoxDriver(); driver.get(\"https://www.facebook.com/\")

How to properly configure Implicit / Explicit Waits and pageLoadTimeout through Selenium?

一个人想着一个人 提交于 2019-11-26 08:38:06
问题 I currently have the following setup, but I\'m not sure that my waits (Implicit and pageLoadTimeout) are working. Is this the proper implementation? By putting it in the @Before(\"@setup\"), does it work for every Scenario or Step Definition run? Will the driver wait accordingly, everytime I call a @Given, @When..etc? @Before(\"@setup\") public void setUp() { driver.manage().deleteAllCookies(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.manage().timeouts()