I am new to selenium.
I tried to save a text from the xpath using storeText and the target is //*[#id='mathq2'].
the base URL is http://timesofindia.indiatimes.com/.
I am getting this error
[info] Executing: |storeText | //*[#id='mathq2'] | wwww |
[error] Invalid xpath [2]: //*[#id='mathq2']
Hi Danny got the same error in timesof india website. This is what i did.
I recorded the element (by entering something in the text box next to it) then clicked on the value like 8+0 = and then selected the radio button above it.
So my selenium showed
click id=mathq2
from there i chose the xpath in the Target dropdown and the xPath seemed to show
//span[#id='mathq2']
so finally I replaced my step for storeText as
storeText //span[#id='mathq2'] addition
and then it stored that value 8+0 = in the variable 'addition'.
You are getting this error, because there is no element with such xPath at the main page of http://timesofindia.indiatimes.com/.
Why do you think it is there?
You can use xPath Checker (Firefox plugin) to check if the xPath is proper and the element exists.
yes, ID is there, but text is changing dynamically.
You need to add the xpath= prefix in your target, and it seems that the xpath is also prepended with a period:
|storeText | xpath=.//*[#id='mathq2'] | wwww |
You would also need to ensure that your script waits for the initial advertisement page to unload.
Related
So, my test has the following command-target-value:
store attribute
id=loadGameButton
*visible*
Trying to find id=loadGameButton... Failed:16:58:58
Implicit Wait timed out after 30000ms
I tried this How to check if a style has been applied in Selenium IDE
And this Selenium IDE cannot find ID
store attribute
css=#loadGameButton#style
*inline*
store attribute
css=[id='loadGameButton']
*inline*
but doesn't work either: it always returns OK without correspondence to what I am trying to check.
https://github.com/Areso/1255-burgomaster/tree/master/selenium-ide
store attribute doesn't check value of attribute, it just save the value of selected element. To check it, you should use assert or verify commands.
store attribute | css=<path_to_element>#style | tmp
assert | tmp | <expected_style_value>
path_to_element - css selector of element
For example, you can use 'width:100%' to replace expected_style_value
I was testing my website using RF. The problem is, every time the modal is opened, a different id(locator) will be set on the textbox that I want to input my text. How do you get value of this locator?
I was supposed to try Get Element Attribute but then it cannot support my problem since it still requires a specific locator.
In ROBOT Framework (RF), the locator can be accessed by several ways. Please refer and read this link: http://robotframework.org/Selenium2Library/Selenium2Library.html
The most common way to access the locator is by id such as :
Input Text id:username # Element with id 'username'.
Input Text id:password # Element with id 'password'. you can also use 'Input Password' keyword.
However, if the 'id' element is so dynamic which it keep changing, then the best alternative is to use either ABSOLUTE XPATH expression or CSS selectors. Install the XPATH add-on in your web browser. For firefox, just install ChroPath.
Then, get the ABSOLUTE Xpath element of that username & password text box. Let's assume we know the absolute xpath expression already, so in ROBOT, you can write like below.
${login_absolute_xpath}= Set Variable xpath=/html[1]//div[7]/form[1]/div[1]/input[1]
${password_absolute_xpath}= Set Variable xpath=/html[1]//div[7]/form[1]/div[2]/input[1]
Wait Until Page Contains Element xpath=${login_absolute_xpath}
Input Text xpath=${login_absolute_xpath}
Input Text xpath=${password_absolute_xpath}
...
This should works. Please let me know if this helps.
I am new to testing and selenium and got lots of doubts, one such is I can assert an element present but how to verify what it is actually, example if I have to check whether a particular field is text area or text box....
so is there any way to do it using selenium IDE?
Thanks in advance...
You can try to use specific for every kind of elements assertions: for example
assertEditable | locator will fail if your field is label, assertText | locator | pattern will work for labels while for text box returned value will be '', assertChecked | locator will fail if your control isn't a toggle-button, assertSelectedLabel | locator | pattern will fail if your control isn't a drop-down and so on.
Also you can just change your elements assertions with tags included into your locators: from id=editField to css=input#editField to be sure that this is an edit field or to css=textarea#editField to be sure that this is multilined textbox and so on.
Not quite sure what the point of your question is...
From the HTML point of view a textbox is and a textarea is . You can specify, and assert on locators that check specifically for these elements, e.g. using XPath locators:
//input[#type='text]
//textarea
I am new in selenium and trying to learning. I am creating a script and I got stuck here, I want to store a dynamic value from text message on web page ex. " Event Name:Test" this Event Name is dynamic and I want to store this and want to get in other window. In 2nd window i want to use this value(Test) to verify in the page
I tried storeValue, StoreText and storeAttribute command and getting error message for xpath or "element not found".
Please help me and advice me , what should I do?
Can You please suggest me the Xpath for storing and retrieving the event name. Please help me...
Thanks in advance,
Niru
If you are using the same test-case to navigate from page 1 to page 2 you can use the storeText function in the IDE to store the value of your event name. And then you can use the same variable in the page 2 for verification.
For example, in page 1 to store the value of event you use:
storeText(locator1, temp)
And then on page 2 you use assert:
assertText(locator2, ${temp})
I'm using the selenium IDE and the Selenium-Fitnesse Bridge fixture and I'm trying to test that when I clear a default value out of a form field, my form displays an error message.
So when I record with the Selenium IDE, what it does is the equivalent of telling Selenium to type nothing.
| type | text_field | |
The problem with this is that the Fitnesse fixture I'm using expects that second argument to not be null.
Is there a way in Selenium to "clear a value" rather than "typing nothing"?
You can do it via javascript as such:
| verifyEval | javascript{this.browserbot.getCurrentWindow().document.getElementById('CONTROL_ID').value = ''} ||
Effectively the verifyEval statement allows you to execute any piece of javascript that you'd like. Makes some difficult problems to accomplish with Selenium much simpler.
I used this tutorial (today believe it or not) to figure things out.
I used this to get it to work. reg_start_date is the id of my input field.
| storeEval | window.document.getElementById('reg_start_date').value = '' |
From the selenium reference:
Note that, by default, the snippet will run in the context of the "selenium" object itself, so this will refer to the Selenium object. Use window to refer to the window of your application, e.g. window.document.getElementById('foo')
Also, avoid wrapping the javascript code with javascript{}, it will not work.
We had this issue at the beginning as well. Try: | type | text_field | blank |
Look for more info on the Fitnesse documentation for the use of blank and null.
:)