splinter

Firefox + Selenium in python: How to interactively get an element html?

徘徊边缘 提交于 2019-12-24 05:59:47
问题 Im using Python + Selenium + Splinter + Firefox to create an interactive web crawler. The python script offers the options, then Selenium opens Firefox and sends some orders. Right now, I need to let the python script know the web element that the user wants to interact with. The method I currently use is: Right-click the item in the website (Firefox), click 'inspect element', then click in the Firefox inspector, click 'copy HTML', then feed it manually to the script, which will then be able

How to find element value using Splinter?

时光怂恿深爱的人放手 提交于 2019-12-23 21:46:38
问题 I have following piece of html: <p class="attrs"><span>foo:</span> <strong>foo</strong></p> <p class="attrs"><span>bar:</span> <strong>bar</strong></p> <p class="attrs"><span>foo2:</span> <strong></strong></p> <p class="attrs"><span>description:</span> <strong>description body</strong></p> <p class="attrs"><span>another foo:</span> <strong>foooo</strong></p> I would like to get description body using splinter. I've managed to get a list of p using browser.find_by_css("p.attrs") 回答1: xpath = '

Django with splinter and phantomjs is painfully slow

强颜欢笑 提交于 2019-12-23 18:33:56
问题 Today I tried combining django's LiveServerTestCase with splinter and phantomjs webdriver. Here's what I do (simplified version): class Test(LiveServerTestCase): def setUp(self): self.browser = Browser('phantomjs') def tearDown(self): self.browser.quit() def test(self): self.browser.visit(self.live_server_url) self.assertIn("Hello world!", self.browser.title) Sometimes tests run fine - even though taking a second per test method to execute. But sometimes it can randomly take ~100 seconds for

how to open two tabs in python splinter

冷暖自知 提交于 2019-12-22 17:37:55
问题 from splinter import Browser with Browser() as browser: browser.visit('https://google.com/') browser.visit('http://www.bing.com/') browser.windows[0] browser.windows[1] How to open two tabs in python splinter and change tab? 回答1: import time from splinter import Browser from selenium.webdriver.common.keys import Keys with Browser() as browser: # visit fst url browser.visit('https://google.com/') # open new tab browser.driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't') #

Python: How to fill out form all at once with splinter/Browser?

≡放荡痞女 提交于 2019-12-21 12:37:26
问题 Currently, I’m filling out the form on a site with the following: browser.fill(‘form[firstname]’, ‘Mabel’) browser.fill(‘form[email]’, ‘hi@hi.com’) browser.select(‘form[color]’, ‘yellow’) But the form gets filled out the form sequentially, one after the other. Is there a way to fill out the form all at once? Thank you and will be sure to vote up and accept the answer! 回答1: Browser has a method called: fill_form(field_values) It takes a dict parameter, with the field names, and the values, and

Manipulating browser (window) size using Splinter

末鹿安然 提交于 2019-12-21 10:05:10
问题 I am trying to use the Firefox driver for Splinter to test some responsive design. Naturally, this requires me to resize the browser window. I can't find anything at all about browser resizing in the documentation. How can I do this? from splinter import Browser with Browser() as browser: # How do I set the browser size? 回答1: Just do this: browser.driver.set_window_size(640, 480) The Splinter API doesn't seem to directly support this - or at least not yet. The generic API docs, as well as the

Filling a password form with Splinter

走远了吗. 提交于 2019-12-18 18:21:35
问题 I'm trying to fill two forms and login to my banks website. I can get the first form for the username to fill but I can't seem to get the form for the password to fill. Here's the code I'm using: from splinter import Browser username2 = '***' password2 = '***' browser2 = Browser() browser2.visit('http://mijn.ing.nl') browser2.find_by_css('.firstfield').fill(username2) browser2.find_by_id('#easnhbcc').fill(password2) and this is the full traceback: /usr/local/bin/python2 "/Users/narekaramjan

Filling a password form with Splinter

流过昼夜 提交于 2019-12-18 18:21:17
问题 I'm trying to fill two forms and login to my banks website. I can get the first form for the username to fill but I can't seem to get the form for the password to fill. Here's the code I'm using: from splinter import Browser username2 = '***' password2 = '***' browser2 = Browser() browser2.visit('http://mijn.ing.nl') browser2.find_by_css('.firstfield').fill(username2) browser2.find_by_id('#easnhbcc').fill(password2) and this is the full traceback: /usr/local/bin/python2 "/Users/narekaramjan

Can not click on a Element: ElementClickInterceptedException in Splinter / Selenium

喜你入骨 提交于 2019-12-18 05:46:06
问题 I'm trying to scrape a page, but I sometimes have trouble clicking a link/button. When the web page loads, then the "loadingWhiteBox" will appear first and then disappear after a few seconds (but it will remain in the HTML code) as long as the box is appears on the website, I can not click on the link and get following error message: selenium.common.exceptions.ElementClickInterceptedException: Message: Element <span class="taLnk ulBlueLinks"> is not clickable at point (318.3000030517578,661

Python Splinter Click Link in Table Conditional

给你一囗甜甜゛ 提交于 2019-12-14 02:49:58
问题 Given this (the "sleep" method is so you can see what I'm looking at): from splinter import Browser import time #from selenium.webdriver.support.ui import WebDriverWait #from selenium.webdriver.remote.webdriver import WebDriver with Browser() as browser: # Visit URL url = "https://mdoe.state.mi.us/moecs/PublicCredentialSearch.aspx" browser.visit(url) browser.fill('ctl00$ContentPlaceHolder1$txtCredentialNumber', 'IF0000000262422') # Find and click the 'search' button button = browser.find_by