Selenium C# WebDriver: Wait until element is present

I want to make sure that an element is present before the webdriver starts doing stuff. I’m trying to get something like this to work: WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, 5)); wait.Until(By.Id(“login”)); I’m mainly struggling how to setup up the anonymous function… 27 Answers 27

WebDriverException: unknown error: DevToolsActivePort file doesn’t exist while trying to initiate Chrome Browser

I am trying to launch chrome with an URL, the browser launches and it does nothing after that. I am seeing the below error after 1 minute: Unable to open browser with url: ‘https://www.google.com’ (Root cause: org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn’t exist (Driver info: chromedriver=2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not … Read more

Wait for page load in Selenium

How do you make Selenium 2.0 wait for the page to load? 48 Answers 48 You can also check pageloaded using following code IWait<IWebDriver> wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(30.00)); wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript(“return document.readyState”).Equals(“complete”));

How to select a drop-down menu value with Selenium using Python?

I need to select an element from a drop-down menu. For example: <select id=”fruits01″ class=”select” name=”fruits”> <option value=”0″>Choose your fruits:</option> <option value=”1″>Banana</option> <option value=”2″>Mango</option> </select> 1) First I have to click on it. I do this: inputElementFruits = driver.find_element_by_xpath(“//select[id=’fruits’]”).click() 2) After that I have to select the good element, lets say Mango. I tried to … Read more

Get HTML source of WebElement in Selenium WebDriver using Python

I’m using the Python bindings to run Selenium WebDriver: from selenium import webdriver wd = webdriver.Firefox() I know I can grab a webelement like so: elem = wd.find_element_by_css_selector(‘#my-id’) And I know I can get the full page source with… wd.page_source But is there a way to get the “element source”? elem.source # <– returns the … Read more