selenium-webdriver

Use Selenium to download file by clicking “javascript:__doPostBack('LeaderBoard1$cmdCSV','')”

社会主义新天地 提交于 2020-12-13 16:14:08
问题 There are a bunch of CSV files of baseball stats that I want to download via automation, which can be found at: https://www.fangraphs.com/leaders.aspx?pos=all&stats=bat&lg=all&qual=0&type=0&season=2020&month=0&season1=2020&ind=0&team=0&rost=0&age=0&filter=&players=0&startdate=2020-01-01&enddate=2020-12-31. The button to download the table as a CSV is labeled 'Export Data'. HTML: <div class="br_dby"> <span style="float: left"> <a href="javascript:ShowHide();">Show Filters</a> | <a href="

Use Selenium to download file by clicking “javascript:__doPostBack('LeaderBoard1$cmdCSV','')”

此生再无相见时 提交于 2020-12-13 16:14:06
问题 There are a bunch of CSV files of baseball stats that I want to download via automation, which can be found at: https://www.fangraphs.com/leaders.aspx?pos=all&stats=bat&lg=all&qual=0&type=0&season=2020&month=0&season1=2020&ind=0&team=0&rost=0&age=0&filter=&players=0&startdate=2020-01-01&enddate=2020-12-31. The button to download the table as a CSV is labeled 'Export Data'. HTML: <div class="br_dby"> <span style="float: left"> <a href="javascript:ShowHide();">Show Filters</a> | <a href="

Use Selenium to download file by clicking “javascript:__doPostBack('LeaderBoard1$cmdCSV','')”

余生长醉 提交于 2020-12-13 16:07:55
问题 There are a bunch of CSV files of baseball stats that I want to download via automation, which can be found at: https://www.fangraphs.com/leaders.aspx?pos=all&stats=bat&lg=all&qual=0&type=0&season=2020&month=0&season1=2020&ind=0&team=0&rost=0&age=0&filter=&players=0&startdate=2020-01-01&enddate=2020-12-31. The button to download the table as a CSV is labeled 'Export Data'. HTML: <div class="br_dby"> <span style="float: left"> <a href="javascript:ShowHide();">Show Filters</a> | <a href="

Wait for element to be clickable using python and Selenium

我是研究僧i 提交于 2020-12-13 10:34:52
问题 There are ways to wait for an object e.g. a button to be clickable in selenium python. I use time.sleep() and/or WebDriverWait...until , it works fine. However, when there are hundreds of objects, is there a way to set a default time lag globally, instead of implementing it on each object? The click() action should have a conditional wait time? 回答1: You can do a few things... Define a global default wait time and then use that in each wait you create. default_wait_time = 10 # seconds ... wait

MaxRetryError: HTTPConnectionPool: Max retries exceeded (Caused by ProtocolError('Connection aborted.', error(111, 'Connection refused')))

℡╲_俬逩灬. 提交于 2020-12-13 03:50:07
问题 I have one question:I want to test "select" and "input".can I write it like the code below: original code: 12 class Sinaselecttest(unittest.TestCase): 13 14 def setUp(self): 15 binary = FirefoxBinary('/usr/local/firefox/firefox') 16 self.driver = webdriver.Firefox(firefox_binary=binary) 17 18 def test_select_in_sina(self): 19 driver = self.driver 20 driver.get("https://www.sina.com.cn/") 21 try: 22 WebDriverWait(driver,30).until( 23 ec.visibility_of_element_located((By.XPATH,"/html/body/div[9

MaxRetryError: HTTPConnectionPool: Max retries exceeded (Caused by ProtocolError('Connection aborted.', error(111, 'Connection refused')))

心不动则不痛 提交于 2020-12-13 03:49:29
问题 I have one question:I want to test "select" and "input".can I write it like the code below: original code: 12 class Sinaselecttest(unittest.TestCase): 13 14 def setUp(self): 15 binary = FirefoxBinary('/usr/local/firefox/firefox') 16 self.driver = webdriver.Firefox(firefox_binary=binary) 17 18 def test_select_in_sina(self): 19 driver = self.driver 20 driver.get("https://www.sina.com.cn/") 21 try: 22 WebDriverWait(driver,30).until( 23 ec.visibility_of_element_located((By.XPATH,"/html/body/div[9

How to wait for number of elements to be loaded using Selenium and Python

徘徊边缘 提交于 2020-12-13 03:23:05
问题 Let's say I'm selecting with the selector: //img[@data-blabla] And I want to wait for 10 elements to be loaded, not just one. How would this be modified? I'm making a guess with the index [9] WebDriverWait(browser, 5).until(EC.presence_of_element_located((By.XPATH, '//img[@data-blabla][9]'))) 回答1: To wait for 10 elements to load you can use the lambda function and you can use either of the following Locator Strategies: Using > : myLength = 9 WebDriverWait(browser, 20).until(lambda browser:

Calculate the position of the button on login page

≡放荡痞女 提交于 2020-12-13 03:10:33
问题 I use this code to calculate the padding of a button on a page from the browser border. Dimension dm = new Dimension(1024,768); //Setting the current window to that dimension driver.manage().window().setSize(dm); // Click Login button to submit login form WebDriverWait loginButtonWebDriverWait = new WebDriverWait(driver, 4000); WebElement loginButtonWebElement = loginButtonWebDriverWait.until(ExpectedConditions.presenceOfElementLocated(By.id("login"))); int loginButtonX =

Calculate the position of the button on login page

那年仲夏 提交于 2020-12-13 03:10:33
问题 I use this code to calculate the padding of a button on a page from the browser border. Dimension dm = new Dimension(1024,768); //Setting the current window to that dimension driver.manage().window().setSize(dm); // Click Login button to submit login form WebDriverWait loginButtonWebDriverWait = new WebDriverWait(driver, 4000); WebElement loginButtonWebElement = loginButtonWebDriverWait.until(ExpectedConditions.presenceOfElementLocated(By.id("login"))); int loginButtonX =

Get a page with Selenium but wait for element value to not be empty [duplicate]

China☆狼群 提交于 2020-12-12 11:57:27
问题 This question already has answers here : How to extract data from the following html? (3 answers) Assert if text within an element contains specific partial text (1 answer) Closed 18 days ago . I'm grabbing a web page using Selenium, but I need to wait for a certain value to load. I don't know what the value will be, only what element it will be present in. It seems that using the expected condition text_to_be_present_in_element_value or text_to_be_present_in_element is the most likely way