Test if element is present but for Powershell

1,413 views
Skip to first unread message

ALIEN Quake

unread,
Nov 1, 2013, 4:12:13 AM11/1/13
to webd...@googlegroups.com
I've added Selenium WebDriver to the Powershell and create WebDriver instance:

Add-Type -path C:\Windows\net40\WebDriver.dll
$driver = New-Object OpenQA.Selenium.Firefox.FirefoxDriver
$driver.Url = "https://www.google.com"
Now I want to find input field:

$singleRecord = ($driver.FindElementByCssSelector("input.gbqfif"))
I found several examples how to "Test if element is present" in C#:



IWebDriver driver = new FirefoxDriver();
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement myDynamicElement = wait.Until<IWebElement>((d) =>
    {
        return d.FindElement(By.Id("someDynamicElement"));
    });

but I cannot create something similar in Powershell, and almost all my tests fails because it takes time for page to load elements.

Dan K

unread,
Jun 27, 2014, 11:20:29 AM6/27/14
to webd...@googlegroups.com
This is an old post, but I had trouble with this as well - you can set up an implicit wait as detailed here: http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp

like this:
$driver = New-Object OpenQA.Selenium.Firefox.FirefoxDriver
$wait = New-TimeSpan -seconds 10
$driver.Manage().Timeouts().ImplicitlyWait( $wait)

ALIEN Quake

unread,
Jul 2, 2015, 5:40:57 AM7/2/15
to webd...@googlegroups.com, mail....@gmail.com
Hi, thanks for reply but this doesn't solve my problem at all. Some websites just hangs whole automation process fails.
Reply all
Reply to author
Forward
0 new messages