selenium

Create a new element by selenium dynamically

时光毁灭记忆、已成空白 提交于 2021-02-19 06:27:19
问题 What I need is to add a script tag to the head of html document. I am using the code below but when I view page source, the script is not there. Thank you in advance, driver = webdriver.Chrome() driver.get("http://www.x.org") execu = ''' var scr = document.createElement('script'); scr.type = 'text/javascript'; scr.text = `let calls = (function(){ let calls = 0; let fun = document.createElement; document.createElement = function(){ calls++; return fun.apply(document, arguments); } return ()=

How do I set environment variables for Selenium Java FirefoxDriver?

这一生的挚爱 提交于 2021-02-19 06:22:28
问题 From within Java unit tests, I want to use Selenium to test my web page with Firefox. My tests require that I set an environment variable for Firefox. (Specifically, I want to set the DISPLAY variable.) The FirefoxBinary class has a method setEnvironmentProperty, which sounds like it should set environment variables for the environment the Firefox process runs in, but in practice it does not have that effect. (I have confirmed that with cat /proc/<firefox_pid>/environ .) Back with selenium

How to efficiently scrape many elements (reviews) on a single page with Selenium

断了今生、忘了曾经 提交于 2021-02-19 06:15:46
问题 I have been trying to scrape all the reviews available at a single url by repeatedly clicking on the button 'Show 6 more reviews' . I believe this problem would apply to anyone scrapping many dynamic elements at a single url with Selenium. Problem: when the number of reviews is more than a few hundreds, the loop becomes very slow. I am using Selenium since the website involves Javascript. HTML of button I am clicking (towards bottom of page) <button type="button" class="css-1e0935c" data-comp

How to efficiently scrape many elements (reviews) on a single page with Selenium

纵然是瞬间 提交于 2021-02-19 06:12:42
问题 I have been trying to scrape all the reviews available at a single url by repeatedly clicking on the button 'Show 6 more reviews' . I believe this problem would apply to anyone scrapping many dynamic elements at a single url with Selenium. Problem: when the number of reviews is more than a few hundreds, the loop becomes very slow. I am using Selenium since the website involves Javascript. HTML of button I am clicking (towards bottom of page) <button type="button" class="css-1e0935c" data-comp

Selenium test works in local machine, but fails on Jenkins

こ雲淡風輕ζ 提交于 2021-02-19 06:12:24
问题 My test works just fine on my machine. However, on Jenkins, I have the following error: Traceback (most recent call last): File "/var/lib/jenkins/jobs/twist-press-ricardo-fork/workspace/.env/local/lib/python2.7/site-packages/django/test/utils.py", line 216, in inner return test_func(*args, **kwargs) File "/var/lib/jenkins/jobs/twist-press-ricardo-fork/workspace/twist/tests/interface/test_hello.py", line 42, in test_login open_login_modal_btn.click() File "/var/lib/jenkins/jobs/twist-press

How to efficiently scrape many elements (reviews) on a single page with Selenium

淺唱寂寞╮ 提交于 2021-02-19 06:12:00
问题 I have been trying to scrape all the reviews available at a single url by repeatedly clicking on the button 'Show 6 more reviews' . I believe this problem would apply to anyone scrapping many dynamic elements at a single url with Selenium. Problem: when the number of reviews is more than a few hundreds, the loop becomes very slow. I am using Selenium since the website involves Javascript. HTML of button I am clicking (towards bottom of page) <button type="button" class="css-1e0935c" data-comp

How to efficiently scrape many elements (reviews) on a single page with Selenium

删除回忆录丶 提交于 2021-02-19 06:11:21
问题 I have been trying to scrape all the reviews available at a single url by repeatedly clicking on the button 'Show 6 more reviews' . I believe this problem would apply to anyone scrapping many dynamic elements at a single url with Selenium. Problem: when the number of reviews is more than a few hundreds, the loop becomes very slow. I am using Selenium since the website involves Javascript. HTML of button I am clicking (towards bottom of page) <button type="button" class="css-1e0935c" data-comp

Selenium test works in local machine, but fails on Jenkins

こ雲淡風輕ζ 提交于 2021-02-19 06:10:43
问题 My test works just fine on my machine. However, on Jenkins, I have the following error: Traceback (most recent call last): File "/var/lib/jenkins/jobs/twist-press-ricardo-fork/workspace/.env/local/lib/python2.7/site-packages/django/test/utils.py", line 216, in inner return test_func(*args, **kwargs) File "/var/lib/jenkins/jobs/twist-press-ricardo-fork/workspace/twist/tests/interface/test_hello.py", line 42, in test_login open_login_modal_btn.click() File "/var/lib/jenkins/jobs/twist-press

How can I make Selenium run in parallel with Scrapy?

末鹿安然 提交于 2021-02-19 06:07:37
问题 I'm trying to scrape some urls with Scrapy and Selenium. Some of the urls are processed by Scrapy directly and the others are handled with Selenium first. The problem is: while Selenium is handling a url, Scrapy is not processing the others in parallel. It waits for the webdriver to finish its work. I have tried to run multiple spiders with different init parameters in separate processes (using multiprocessing pool), but I got twisted.internet.error.ReactorNotRestartable . I also tried to

How can I make Selenium run in parallel with Scrapy?

不想你离开。 提交于 2021-02-19 06:05:36
问题 I'm trying to scrape some urls with Scrapy and Selenium. Some of the urls are processed by Scrapy directly and the others are handled with Selenium first. The problem is: while Selenium is handling a url, Scrapy is not processing the others in parallel. It waits for the webdriver to finish its work. I have tried to run multiple spiders with different init parameters in separate processes (using multiprocessing pool), but I got twisted.internet.error.ReactorNotRestartable . I also tried to