How to use if/else statement in Selenium IDE - selenium

First look at the picture. Now if the edit link is present, I have to perform some steps, if edit link is not present, I have to perform different steps. How can I do this in Selenium IDE.

Take a look at this:
I provided comments for you to easily understand.
I've been using the gotoIf command as an alternative for the if-else statement for a while. Let me know if you have more questions.

here is example of if else on ide . On ide you will see three columns command , target and value
Command |Target | value
store | true | var1
if | storedVars.var1
echo | I am in the if
else
echo | I am in the else
endIf
If you have any further question than feel free to contact here

As far as I know there is no 'if' command in Selenium IDE. However, you're lucky there sure is 'gotoIf'!
This is how you can use 'gotoIf' command to perform the required steps if the 'Edit' link is present:
Checking a condition using 'gotoIf'
Hope this helps. Do let me know in case of any questions.

Related

PyCharm Selenium not openening Chrome, "Process finished with exit code 0" [duplicate]

I am new to PyCharm and I have 'Process finished with exit code 0' instead of getting (683, 11) as a result (please see attachment), could you guys help me out please? Much appreciate it!
That is good news! It means that there is no error with your code. You have run it right through and there is nothing wrong with it. Pycharm returns 0 when it has found no errors (plus any output you give it) and returns 1 as well as an error message when it encounters errors.
Editors and scripts do not behave like the interactive terminal, when you run a function it does not automatically show the the result. You need to actually tell it to do it yourself.
Generally you just print the results.
If you use print(data.shape) it should return what you expect with the success message Process finished with exit code 0.
exit code 0 means you code run with no error.
Let's give a error code for example(clearly in the below image): in below code, the variable lst is an empty list,
but we get the 5 member in it(which not exists), so the program throws IndexError, and exit 1 which means there is error with the code.
You can also define exit code for analysis, for example:
ERROR_USERNAME, ERROR_PASSWORD, RIGHT_CODE = 683, 11, 0
right_name, right_password = 'xy', 'xy'
name, password = 'xy', 'wrong_password'
if name != right_name:
exit(ERROR_USERNAME)
if password != right_password:
exit(ERROR_PASSWORD)
exit(RIGHT_CODE)
I would recommend you to read up onexit codes.
exit 0 means no error.
exit 1 means there is some error in your code.
This is not pyCharm or python specific. This is a very common practice in most of the programming languages. Where exit 0 means the successful execution of the program and a non zero exit code indicates an error.
Almost all the program(C++/python/java..) return 0 if it runs successful.That isn't specific to pycharm or python.
In program there is no need to invoke exit function explicitly when it runs success it invoke exit(0) by default, invoke exit(not_zero_num) when runs failed.
You can also invoke exit function with different code(num) for analysis.
You can also see https://en.wikipedia.org/wiki/Exit_(system_call) for more details.
What worked for me when this happened was to go to
Run --> Edit Configurations --> Execution --> check the box Run with
Python Console (which was unchecked).
This means that the compilation was successful (no errors). PyCharm and command prompt (Windows OS), terminal (Ubuntu) don't work the same way. PyCharm is an editor and if you want to print something, you explicitly have to write the print statement:
print(whatever_you_want_to_print)
In your case,
print(data.shape)
I think there's no problem in your code and you could find your print results (and other outputs) in the tab 5: Debug rather than 4: Run.
I just ran into this, but couldn't even run a simple print('hello world') function.
Turns out Comodo's Firewall was stopping the script from printing. This is a pretty easy fix by deleting Python out of the Settings > Advanced > Script Analysis portion of Comodo.
Good Luck
I had same problem with yours. And I finally solve it
I see you are trying to run code "Kaggle - BreastCancer.py"
but your pycharm try to run "Breast.py" instead of your code.
(I think Breast.py only contains functions so pycharm can run without showing any result)
Check on tab [Run] which code you are trying to run.
Your starting the program's run from a different file than you have open there. In Run (alt+shift+F10), set the python file you would like to run or debug.

Store windows.performance Values In Selenium IDE

This is a slight repeat of How to capture page load times in Selenium-IDE using the app.telemetry page speed monitor
However, the answer in that post does not seem to work (or doesnt anymore), possibly because the storeEval command in Selenium IDE doesnt seem to exist anymore.
I'm trying to retrieve certain windows.performance values for webpages as Selenium IDE moves through them.
I have tried:
Command 'open' > Target 'www.url.com'
Command 'store value' > Target window.performance.timing['navigationStart'] > Value 'result'
Command 'echo' > Target ${result}
But I get:
Warning implicit locators are deprecated, please change the locator to id=window.performance.timing['navigationStart']
The above doesn't work, as obviously its not an id.
Am I using the wrong Command? Or have to enter additional target details? Or can it be done at all?
Thanks!
Use execute script instead:
Command Target Value
open http://www.example.com/
execute script return window.performance.timing['navigationStart'] result
echo ${result}

use output test case with other test case in input value, RIDE/robot framework

I have a probelm to use an output from a test case to use it with another test tase like input value ! did you have an idea how to do that ?
Even I have seen this issue with Ride. Sometimes ride does not save changes. Need to restart ride to see the saved changes. So, I am using ride only for development purpose and using command line to run test cases. On one window edit changes in ride and run test cases on command line.
To run single test case from command line:
python -m robot -t test_case_name test_suite_name
Hope it clears your doubt.

Selenium IDE "[error] Threw an exception: illegal character" error while using storeEval command

I am writing following test case:
COMMAND TARGET VALUE
--------------------------------------------------------------
storeXpathCount *someXpath* totalRows
store 3 i
while ${i}<=${totalRows}
storeText *someXpath* MyVersion
storeEval storedVars['MyVersion']=='103' result
gotoIf ${result}==false lebelForIf
label labelForIf
storeEval {i}+1 i
endWhile
I am getting error at the line where i have storeEval storedVars[..]
The error is "[error] Threw an exception: illegal character".
Basically i want to search a version ( i.e. 103) from column which has "totalrows" thus iterating using i, wherever the version matches I want to take some action.
If the above snippet is not proper is there any other way to write this code in Selenium IDE?
I dont think the while loops are supported in Selenium IDE directly. We have to install user extensions for this.
Refer to the following link for more info - How to use loops in Selenium IDE
Let me know if this helps you.

Rspec output format

This question is more out of curiosity than purpose. Can we change the output of Rspec command, where it shows dots and Fs. For example, here is an output from one of my projects:
.F.F.F.F
.....
........
Finished in 0.27137 seconds
8 examples, 4 failures
Can we get Pass Failed Pass Failed Pass Failed Pass Failed instead of .F.F.F.F
You indeed can, check out the rspec wiki or google 'rspec progressformatter' -- here's one that does something very close to what you want.
Color might help a bit - add the alias spec=spec --color --format specdoc to your ~/.bashrc file.