ajitjaiswal50 / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
0 stars 0 forks source link

Problem with findElementById method #37

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Operating system and version (32/64bit) : XP SP3 (32bit)
.Net Framework version :
Office name and version(32/64bit) :
Browser name and version : Firefox 26
SeleniumWrapper version : 1.0.17.0

First, I would like to thank you for SeleniumWrapper. It is excellent tool !
1. Me tried to edit your QuickTest.vbs file in order to access text in input 
element but it doesnt work as me expected

Dim selenium, mytext
Set selenium = CreateObject("SeleniumWrapper.WebDriver")
......
' mytext = selenium.getValue("lst-ib")
mytext = selenium.findElementById("lst-ib").Text
wscript.echo "Searched for: " & mytext  
selenium.stop

What is the expected output? What do you see instead?
The empty string was returned by
 selenium.findElementById("lst-ib").Text

if i use mytext = selenium.getValue("lst-ib") it works and "Eiffel tower" is 
returned

2. I tried to use WebElement like this:
Dim selenium, element, mytext
Set selenium = CreateObject("SeleniumWrapper.WebDriver")
Set element = CreateObject("SeleniumWrapper.WebElement")
element = selenium.findElementById("lst-ib")
mytext = element.Text

it crashed with "ActiveX component can't create object 
"SeleniumWrapper.WebElement". 
BTW, i dont see SeleniumWrapper.WebElement entry in registry.

Could you please provide your expert opinion ?

Thanks in advance !

Original issue reported on code.google.com by alex.fir...@gmail.com on 29 Dec 2013 at 12:13

Attachments:

GoogleCodeExporter commented 8 years ago
The text typed in an input is stored in the attribute named "value" and not as 
inner text (see by yourself the html source).
That's why there is no text returned in your case.
The equivalent to getValue("id") is findElementById("id").getAttribute("value").

Here is an example :
Set driver = CreateObject("SeleniumWrapper.WebDriver")
driver.start "firefox", "http://www.google.com"
driver.open "/"
driver.type "name=q", "Eiffel tower"
driver.keyPress "name=q", "\13"
wscript.echo driver.getValue("name=q")   'Selenium 1
wscript.echo driver.findElementByName("q").getAttribute("value")     'Selenium 2

Original comment by florentbr on 29 Dec 2013 at 1:11

GoogleCodeExporter commented 8 years ago
findElementById("id").getAttribute("value") works ! Thank you !

Am i right - object SeleniumWrapper.WebElement is not registered ? Therefore  
Set element = CreateObject("SeleniumWrapper.WebElement")
is crashed with "ActiveX component can't create object 
"SeleniumWrapper.WebElement". 

Original comment by alex.fir...@gmail.com on 30 Dec 2013 at 8:38

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by florentbr on 8 Sep 2014 at 5:40