selenium-webdriver

Python selenium don't autoplay videos

China☆狼群 提交于 2021-01-27 16:54:14
问题 I am using the Selenium webdriver in Python and I'd like the browser to not load images or autoplay videos to save time and resources. The problem is that videos do still get played without clicking on them. Here are my settings for the webbrowser: from selenium import webdriver firefox_profile = webdriver.FirefoxProfile() # don't load images firefox_profile.set_preference('permissions.default.image', 2) firefox_profile.set_preference('extensions.contentblocker.enabled', True) firefox_profile

Python selenium don't autoplay videos

我与影子孤独终老i 提交于 2021-01-27 16:42:00
问题 I am using the Selenium webdriver in Python and I'd like the browser to not load images or autoplay videos to save time and resources. The problem is that videos do still get played without clicking on them. Here are my settings for the webbrowser: from selenium import webdriver firefox_profile = webdriver.FirefoxProfile() # don't load images firefox_profile.set_preference('permissions.default.image', 2) firefox_profile.set_preference('extensions.contentblocker.enabled', True) firefox_profile

How to handle “Unable to receive message from renderer” in chrome driver?

半世苍凉 提交于 2021-01-27 16:04:26
问题 Test Environment: chrome=73.0.3683.103 chromedriver version: 73.0.3683.68 java.version: '1.8.0_151' os.name: 'Windows 7' I am getting following error: Unable to receive message from renderer Timed out receiving message from renderer: 19.997 Timed out receiving message from renderer:-0.004 Thank you in advance for any help you may be able to provide. 回答1: This error message... Unable to receive message from renderer Timed out receiving message from renderer: 19.997 Timed out receiving message

python selenium - takes a lot of time when it does not find elements

十年热恋 提交于 2021-01-27 13:12:16
问题 my code scans a lot of internet pages with chromedriver and searches for the same element in each page with "find_elements_by_xpath" Lines = driver.find_elements_by_xpath( '//*[@id="top"]/div[contains(@style, "display: block;")]/' 'div[contains(@style, "display: block;")]//tbody//a[contains(@title, "Line")]') When it finds, one or multiple, it works fast and good. But, when the XPath doesn't exist it runs for 6-7 seconds and then moves on. Can I limit the search for 1 second, And if it doesn

How to Click the “OK” Button within an Alert using Python + Selenium

心不动则不痛 提交于 2021-01-27 12:52:53
问题 I want to click the "OK" button in this pop up dialog I tried: driver.switchTo().alert().accept(); but it doesn't work 回答1: To click on the OK button within the alert you need to induce WebDriverWait for the desired alert_is_present() and you can use the following solution: WebDriverWait(driver, 10).until(EC.alert_is_present()) driver.switch_to.alert.accept() Note : You have to add the following imports : from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support

Selenium WebDriver loses connection to web page

妖精的绣舞 提交于 2021-01-27 12:45:27
问题 I'm executing an automated test with Selenium ChromeDriver against a form on a web page. When I click the Submit button on the form, my WebDriver is losing connection to the browser/page/components, etc. Any subsequent action against the page objects or the browser results in timeouts because it no longer has a connection. It's as if the submit causes the underlying connection to break. This is the error I get and it's a similar error no matter if I'm trying to click a page object, manipulate

What is the correct syntax checking the .readyState of a website in Selenium Python?

六眼飞鱼酱① 提交于 2021-01-27 12:19:03
问题 I'm trying to check the .readyState of a website using .execute_script but I keep getting an error. I'm using a pageLoadStrategy of "none" in chromedriver so I'm trying to test that the websites readystate is no longer "loading". Note: this question is Python-specific. WebDriverWait(driver, timeout=20).until( driver.execute_script('return document.readyState') == 'interactive' ) value = method(self._driver) TypeError: 'str' object is not callable I've also tried using lambda which doesn't

What is the correct syntax checking the .readyState of a website in Selenium Python?

扶醉桌前 提交于 2021-01-27 12:16:00
问题 I'm trying to check the .readyState of a website using .execute_script but I keep getting an error. I'm using a pageLoadStrategy of "none" in chromedriver so I'm trying to test that the websites readystate is no longer "loading". Note: this question is Python-specific. WebDriverWait(driver, timeout=20).until( driver.execute_script('return document.readyState') == 'interactive' ) value = method(self._driver) TypeError: 'str' object is not callable I've also tried using lambda which doesn't

System.InvalidOperationException : Unable to create new service: ChromeDriverService with ChromeDriver and SeleniumGrid on local machine

泄露秘密 提交于 2021-01-27 08:54:19
问题 I had set up Selenium Grid (Both Hub and Node) on my local machine which runs on Windows 10 using below command for registering Hub. java -jar selenium-server-standalone-3.141.59.jar -role hub and for registering a Node, I had used below command java -jar selenium-server-standalone-3.141.59.jar -role node -hub http://10.37.34.2:4444/grid/register -port 5454 On Command Prompt, it displayed that "The node is registered to the hub and ready to use" Verified Grid Console as well at http:/

System.InvalidOperationException : Unable to create new service: ChromeDriverService with ChromeDriver and SeleniumGrid on local machine

我的梦境 提交于 2021-01-27 08:53:02
问题 I had set up Selenium Grid (Both Hub and Node) on my local machine which runs on Windows 10 using below command for registering Hub. java -jar selenium-server-standalone-3.141.59.jar -role hub and for registering a Node, I had used below command java -jar selenium-server-standalone-3.141.59.jar -role node -hub http://10.37.34.2:4444/grid/register -port 5454 On Command Prompt, it displayed that "The node is registered to the hub and ready to use" Verified Grid Console as well at http:/