Selenium 2.53 not working on Firefox 47

Unfortunately Selenium WebDriver 2.53.0 is not compatible with Firefox 47.0. The WebDriver component which handles Firefox browsers (FirefoxDriver) will be discontinued. As of version 3.0, Selenium WebDriver will need the geckodriver binary to manage Firefox browsers. More info here and here. Therefore, in order to use Firefox 47.0 as browser with Selenium WebDriver 2.53.0, you … Read more

How to deal with certificates using Selenium?

For the Firefox, you need to set accept_untrusted_certs FirefoxProfile() option to True: from selenium import webdriver profile = webdriver.FirefoxProfile() profile.accept_untrusted_certs = True driver = webdriver.Firefox(firefox_profile=profile) driver.get(‘https://cacert.org/’) driver.close() For Chrome, you need to add –ignore-certificate-errors ChromeOptions() argument: from selenium import webdriver options = webdriver.ChromeOptions() options.add_argument(‘ignore-certificate-errors’) driver = webdriver.Chrome(chrome_options=options) driver.get(‘https://cacert.org/’) driver.close() For the Internet Explorer, you need … Read more

Scrolling to element using webdriver?

You are trying to run Java code with Python. In Python/Selenium, the org.openqa.selenium.interactions.Actions are reflected in ActionChains class: from selenium.webdriver.common.action_chains import ActionChains element = driver.find_element_by_id(“my-id”) actions = ActionChains(driver) actions.move_to_element(element).perform() Or, you can also “scroll into view” via scrollIntoView(): driver.execute_script(“arguments[0].scrollIntoView();”, element) If you are interested in the differences: scrollIntoView vs moveToElement

How to select specified node within Xpath node sets by index with Selenium?

This is a FAQ: //someName[3] means: all someName elements in the document, that are the third someName child of their parent — there may be many such elements. What you want is exactly the 3rd someName element: (//someName)[3] Explanation: the [] has a higher precedence (priority) than //. Remember always to put expressions of the … Read more

Get all child elements

Yes, you can achieve it by find_elements_by_css_selector(“*”) or find_elements_by_xpath(“.//*”). However, this doesn’t sound like a valid use case to find all children of an element. It is an expensive operation to get all direct/indirect children. Please further explain what you are trying to do. There should be a better way. from selenium import webdriver driver … Read more

How can I ask the Selenium-WebDriver to wait for few seconds in Java?

Well, there are two types of wait: explicit and implicit wait. The idea of explicit wait is WebDriverWait.until(condition-that-finds-the-element); The concept of implicit wait is driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); You can get difference in details here. In such situations I’d prefer using explicit wait (fluentWait in particular): public WebElement fluentWait(final By locator) { Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) … Read more

Running Selenium Webdriver with a proxy in Python

Works for me this way (similar to @Amey and @user4642224 code, but shorter a bit): from selenium import webdriver from selenium.webdriver.common.proxy import Proxy, ProxyType prox = Proxy() prox.proxy_type = ProxyType.MANUAL prox.http_proxy = “ip_addr:port” prox.socks_proxy = “ip_addr:port” prox.ssl_proxy = “ip_addr:port” capabilities = webdriver.DesiredCapabilities.CHROME prox.add_to_capabilities(capabilities) driver = webdriver.Chrome(desired_capabilities=capabilities)

Checking if an element exists with Python Selenium

For a): from selenium.common.exceptions import NoSuchElementException def check_exists_by_xpath(xpath): try: webdriver.find_element_by_xpath(xpath) except NoSuchElementException: return False return True For b): Moreover, you can take the XPath expression as a standard throughout all your scripts and create functions as above mentions for universal use. I recommend to use CSS selectors. I recommend not to mix/use “by id”, “by … Read more