I am trying to automate webpage(www.redfin.com) using selenium webdriver from excel. According to Firebug, I have successfully located the text input element and the submit element. When I test it from excel, it looks like the text are entered but the submit is not working even if I click the submit button manually.
I have managed to track the dynamically changing attribute(data-reactid). This is what I have tried,
Public Sub text()
Dim sel As New SeleniumWrapper.WebDriver
with sel
.start "chrome", "https://www.redfin.com/
.Open "/"
.Click "xpath=//input[contains(@data-reactid, '$0.0.0.0.0.1.0')]"
.Type "xpath=//input[contains(@data-reactid, '$0.0.0.0.0.1.0')]", "5720 lansdowne ave Philadelphia, PA"
.Click "xpath=//input[contains(@data-reactid, '$0.0.0.0.0.0')]"
.stop
end with
End Sub
And this is part of the html code
<form class="SearchBoxForm" data-reactid=".1k616yjndog.0.1.0.0.0.1.$0.0.0.0">
<div class="search-container inline-block" data-reactid=".1k616yjndog.0.1.0.0.0.1.$0.0.0.0.0">
<input class="inline-block SearchButton clickable float-right" type="submit" data-reactid=".1k616yjndog.0.1.0.0.0.1.$0.0.0.0.0.0" title="Search" value="" data-rf-test-name="searchButton">
<div class="InputBox" data-reactid=".1k616yjndog.0.1.0.0.0.1.$0.0.0.0.0.1">
<input class="search-input-box" type="text" data-reactid=".1k616yjndog.0.1.0.0.0.1.$0.0.0.0.0.1.0" title="City, Address, School, Agent, Zip" placeholder="City, Address, School, Agent, Zip" value="5600 Lansdowne Ave" aria-invalid="false" tabindex="1" aria-haspopup="true" role="textbox" autocomplete="off" name="searchInputBox" data-rf-test-name="searchBox">
<input class="btn-clear-search-input clickable" type="button" data-reactid=".1k616yjndog.0.1.0.0.0.1.$0.0.0.0.0.1.1" title="Clear">
</div>
</div>
<noscript data-reactid=".1k616yjndog.0.1.0.0.0.1.$0.0.0.0.1"></noscript>
</form>
As always, I really appreciate any help. Thank you.
Guys Webdriver sendkey did the trick. Here is how ..
With Sel
.start "chrome", "https://www.redfin.com/"
.Open "/"
.Click "xpath=//input[contains(@data-reactid, '$0.0.0.0.0.1.0')]"
.findElementByXPath("//input[contains(@data-reactid, '$0.0.0.0.0.1.0')]").SendKeys "5617 Lansdowne Ave Philadelphia, PA"
.executeScript "window.open('http:\\www.realtor.com','_blank')" 'open New Tab
.switchToWindow -1 'switch to new tab
.findElementByCssSelector("#Location").SendKeys "5617 Lansdowne Ave Philadelphia, PA"
.Click "id=btnSearchHomePage"
End With
I am going to spend time learning selenium 2 rather than using IDE. I hope this will help someone else too.