Reload page if stored Text is a certain value using Selenium IDE? - selenium

I am using storeText | css=strong | k
to pull a value from my webpage.
If the value put in 'k' is "reload" I want to refresh the page.
Which function in selenium IDE can accomplish this?
Thank you!

First check what the value is in k , then you can use
refresh
or probably
refreshAndWait
for page refresh.
Source : http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automation/selenium-ide/114-selenium-ide-complete-list-of-commands

Related

Selenium XPath for WebTable using parent & sibling

I am trying to automate the web table on the demoqa site https://demoqa.com/webtables where I am aiming to click the edit and delete button for a specific user. Please find the attached screenshot for reference.
Screenshot
I am trying to click the edit and delete button for the user 'Cierra' hence I have created the customize XPath '//div[contains(text(),'cierra#example.com')]//following::div[text()='Insurance']//following::div//div//span[#title='Edit']'
Trying to click the edit and delete button using the contains text with email 'cierra#example.com' however I see four results even I use the unique username. Could anyone help me with this?
(//div[contains(text(),'cierra#example.com')]//following::div[text()='Insurance']//following::div//div//span[#title='Edit'])[1]
you can enclose the result in bracket and call [1] , to get first one:
But you don't have to over complicate it , just get email then go back to parent and get span under that parent ,:
//div[contains(text(),'cierra#example.com')]/..//span[#title="Edit"]
if you still want to use fancy xpath locator then use :
//div[contains(text(),'cierra#example.com')]/following-sibling::div[contains(text(),'Insurance')]/following-sibling::div//span[#title='Edit']

How to select value from Google auto location using Selenium

How to automate this to select particular value even the dropdown list id cannot be inspected. Can anyone help me out on this?
Need to select U.S. 22 Imperial from the list
Please find the HTML snippet
I am unable to proceed more than this. Please help me out!
WebElement location = driver.findElement(By.id("selectbox-city-list2"));
location.sendKeys("us");
You could use sendKeys and send arrow down to select an option. Selecting one by one with the arrow down will highlight the value. You will be able to check the highlighted value using the CSS class of highlighting.
You can use ActionClass
using this you can move your cursor over a specific element based on coordinates and perform a click.
1.So taking the coordinates of that text box.
2.Enter the full value in the text box. ,
3.calculate a very near coordinate to that text box(so that it will be the suggestion) and perform a click.
element = xxxxxxx;
Actions builder = new Actions(driver);
builder.moveToElement(element, x_coord, y_coord).click().build.perform();

How to get button id and extract a part of it?

Table has many similar buttons. Each of them has different id number. By using Selenium IDE 2.5 I can place these buttons at the top left corner cell of table. I can press that button with selenium by using button class. The thing is - I need that button id number. Can I extract and store it?
For example, particular button id is SYS01_666 and button class is spark-InfoButton.
I need to extract numbers "666" and store it by locating button by it's class. Is it possible?
I'm not sure if it is clear, what is my problem, because I am not a programmer.
Store the id of the button in a variable(eg. ButtonId) using storeAttribute command.
And then to perform any sort of extraction operations on the variable use
Command : store ||
Target : javascript{storeVars['ButtonId']}.substr(x,y) ||
Value : a different variable to store the extracted text

How to read all values of dropdown in Selenium IDE

How to read all values of dropdown in Selenium IDE?
I have a dropdown which have values in it (for eg Dates), I need to select each value and click on submit button and generate the report again select the next value... the loop continues till the end of dropdown values.
How can i do this with Selenium IDE?
You can use a loop, the loop will cycle through the option in the dropdown.
List<WebElement> dropdown = driver.findElements(locator));
for(WebElement t : dropdown) {
String valueText = t.getText();
Select value = new Select(driver.findElement(locator);
value.selectByVisibleText(valueText);
buttonSubmit.click;
}
This is a little tricky to achieve elegantly within Selenium-IDE. As Apjuh mentioned, a loop would be the best way to select each value. Unfortunately, Selenium-IDE does not have any flow control commands by default. There are two choices here:
1) Implement every iteration of the loop manually. Not recommended.
2) Download and install the Flow Control plugin for Selenium-IDE. I don't have any experience using it myself, but I might try it for a bit now and report back with results.
From there, it ought to be possible to construct a loop that does what you need to do.
Edit: After having done battle with Selenium-IDE for the last half-hour, I can only conclude that Selenium-IDE probably isn't the best tool for the job here! The following commands do successfully imitate a for loop:
store | 0 | i
label | loopStart
getEval | alert("i = " + storedVars.i)
store | javascript{storedVars.i++;}
gotoIf | storedVars.i < 4 | loopStart
...but getting it to play well with a dropdown box (e.g. selecting the option at index i) was proving problematic and ultimately far too much hassle for what should be a simple task. If at all possible, I think it would be worth looking into Selenium WebDriver, which would allow the use of actual code. Using C#, Apjuh's answer would perform the job perfectly well, and I imagine it didn't take him half an hour to get that far!

Value Loading from a drop down into other textbox

I uses the selenium for GWT UI testing. It is working properly.
But it is unable to load the drop down in textbox.
for example : When I search "test" in box , it provide me a drop down with a list of value having "test" (test 123 right). Now these value will load in to other boxes which are disabled.
I think selenium is not trigger keydown event . How can it be possible ?
Thanks in advance.
you can use suggestbox instead of textbox. http://examples.roughian.com/index.htm#Widgets~SuggestBox
You can try selenium.select("css=input.GDPNTKNCHI", "value=REQUIRED VALUE") which should select it from the drop down.