i have recorded a list of all the webpages i need to test (>400).
now i would like to tell selenium-ide to do a verification on all these pages.
### example: what i usually do: ###
1. open /test/page1
2. VerifyTextNotPresent "ERROR"
3. open /test/page2
4. VerifyTextNotPresent "ERROR"
5. open /test/page3
6. VerifyTextNotPresent "ERROR"
7. ...
as you notice, the test itself (identifying the "ERROR") has to be written 400 times for the 400 pages that have to be tested.
i will end up with 400 lines saying "VerifyTextNotPresent "ERROR"" + 400 lines opening the webpages = 800 lines in selenium-ide.
### example: what i would like to do: ###
1. VerifyTextNotPresent "ERROR" FOR all these ...
2. open /test/page1
3. open /test/page2
4. open /test/page3
5. ...
if this would be possible, i would end up with 401 lines instead of 800 and in case of a change, lets say another test (AssertText "ABC") it would only need little work to do so.
You can use looping and parametrization..where for each iteration you can pass new webpage URL and will check whether ERROR is there or not.
open | pass URL (parametrization)
while loop
then you can check with
if ERROR text present
Do this
Else
Do this
endWhile
With this there is no need to write that command again again..you can run this loop 400 times with new URL every time.
let me know if there is any doubt.
here are some usefull answers for using javascript capability (such as "while") in selenium.
=> "onlineseleniumtraining.com
=> stackoverflow.com
special thanks to karina!!!
Related
MATLAB provides the extractFileText function which allows us to read text from PDF files, among other file formats, and save the extracted text as a string.
We can pass an extra argument to this function in order to extract text from specific pages of the document.
For example, to extract the text from pages 3, 5 and 7 from the sample exampleSonnets.pdf file:
str = extractFileText("exampleSonnets.pdf", 'Pages', [3 5 7]);
This function, however, does not provide a way of finding out the total number of pages that the PDF document contains beforehand.
So if we happen to do something like:
str = extractFileText("exampleSonnets.pdf", 'Pages', [99 100]);
The following error is thrown:
Error using extractFileText (line 95)
No page 100 in file. Maximum page number: 47.
Warning us that we have requested a page number that exceeds the actual total number of pages in the document.
This is fine.
However, how can I know the total number of pages in a PDF document beforehand, without triggering the error, so that I can safely narrow my searches to the maximum page number?
Is there a function for this purpose?
I'm not aware of a way that ould let you do this. But you can use try/catch to handle the situation directly without knowing the number of pages beforehand.
If you do need to know the number of pages beforehand you could just iterate through the pages until you hit an error that you do handle using try/catch (works for small pdfs) or implement e.g. a binary search in a similar way.
flawr's idea is actually very clever!
In fact, since the maximum page number is contained in the error message, we can trigger the exception (asking for any ridiculously big page number on purpose), catch it, and then parse the error message to recover the maximum page number.
No page 100 in file. Maximum page number: 47.
^
This is all we need
So we don't even need to iterate through every page of the document :)
I went ahead and made this simple numpages function:
function [num] = numpages(filename)
% Queried page number. Any big number should do.
bignum = 1e6;
try
extractFileText(filename, 'Pages', bignum);
catch ME
if strcmp(ME.identifier, 'textanalytics:extractFileText:NoSuchPage')
% Extract the Maximum page number from the exception message.
num = str2double(extractBetween(ME.message, "number: ", "."));
else
% Not the exception we are interested in. Rethrow it.
rethrow(ME);
end
end
end
Test case:
>> numpages("exampleSonnets.pdf")
ans =
47
It works!
I have a variable in one of the scenario of a feature file which I need to use in the request body of second feature file.
For Example:
A.feature
Scenario: Test
Given url 'abc'
* def number = 12345
And request {tyu:'#(number)',dhd:'lkj'}
When method put
Then status 200
B.feature
Scenario: Test2
Given url 'pqr'
And request {tyu:'#(number)'}
When method put
Then status 200
Note: Number variable in A.feature is a 6 digit number which is randomly generated everytime and the same should be passed in B.feature file.
Normally if you have two Scenario-s that depend on one another you have to combine them into one. Refer the docs here: https://github.com/intuit/karate#script-structure
But if you are really looking for how to initialize something and re-use it across all feature files, maybe you are looking for karate.callSingle(): https://github.com/intuit/karate#hooks
var result = karate.callSingle('get-token.feature');
I have a matlab script, where I would like to dynamically create sections in my matlab publish.
At present, the only way I know to create a section break, is to put code like this in my script:
%% This is a section break
I'd like to run publish on my script, and have the section breaks get added as part of the publish. For instance. Say I had the following script:
breaks(1).name = 'This is section break 1.';
breaks(2).name = 'This is section break 2.';
for ix = 1 : numel(breaks)
functionThatInsertsSectionBreakTitle(breaks(ix).name);
fprintf('Some random processing associated with break %d.\n', ix);
end
I would like to call publish on that script, and end up with a document that looks something like:
This is section break 1.
Some random processing associated with break 1.
This is section break 2.
Some random processing associated with break 2.
Obviously I could do this by writing a script that writes a script that then gets executed by publish. I was hoping for something a bit more direct. Am aware of the report generation toolbox, which I would hope would cleanly handle this type of scenario. Alternatively, if the new (as of R2016a) Live Script handles this use case, that's a fine answer as well.
One way to address this problem is by displaying html code in the command output (documented here).
In your example, the code would look like this:
breaks(1).name = 'This is section break 1.';
breaks(2).name = 'This is section break 2.';
for ix = 1 : numel(breaks)
disp(['<html><h2>' breaks(ix).name '</h2></html>']);
fprintf('Some random processing associated with break %d.\n', ix);
end
This is incredibly useful when you want to get results to be displayed with a custom layout, such as a table. And it avoids the need of having a Matlab Report Generator license...
I am looking for a solution in google spreadsheet to check if a domain has any content on its site or shows a blank page/brings a 404 error.
I am looking for a way to get two different outcomes (1 and 0) by these requirements:
1 if domain is existing and there is content on this domain
0 if domain is not existing
0 if domain is existing but can't be reached (404)
0 if domain is existing and can be reached but has a blank page
Examples are found in the following spreadsheet: https://docs.google.com/spreadsheets/d/1gcdF_NdhYX4vBJgwP-cAVsTmeO2WgrynND2f63Zi3Lk/edit#gid=0
I was trying to get some date from the domains with IMPORTDATA, IMPORTHTML and IMPORTXML (as a next step I would add another column that gives me 1 if content is not cell is not empty, 0 else:
=if(isna(IMPORTDATA(A1))=FALSE;1;0)
=if(isna(importhtml(A9;"list";1));"";transpose(IMPORThtml(A9;"list";1)))
=IMPORTXML(A13;"//h:h1")
But these formulas are not reliable enough to handle the task.
I'd be a big fan of IMPORTXML, but as I read so far it is currently not working in new google spreadsheets (not even the official examples are working for me...).
Is there any way to solve this problem for about 1000 domains?
Thanks in advance!
You can try creating a script in the script editor:
function SOverflowChecker( uri )
{
var response_code ;
try {
response_code = UrlFetchApp .fetch( uri ) .getResponseCode() .toString() ;
}
catch( error ) {
response_code = error .toString() .match( / returned code (ddd)./ )[1] ;
}
finally {
return response_code ;
}
}
Save it then in the cell use this code:
=SOverflowChecker(RowValueOfURL)
RowValueOfURL being the row for whatever your URL is on.
So for example if the URL is in B2:
=SOverflowChecker(B2)
It will check the website and return a status code, based on the status code you can evaluate the URL is dead or alive.
Reference:
http://www.tinkeredge.com/blog/web-usability/check-on-page-for-broken-links-with-google-docs/
Hope this helps
I'm in a web scripting class, and honestly and unfortunately, it has come second to my networking and design and analysis classes. Because of this I find I encounter problems that may be mundane but can't find the solution to it easily.
I am writing a CGI form that is supposed to work with a MySQL DB. I can insert and delete into the DB just fine. My problem comes when querying the DB.
My code compiles fine and I don't get errors when trying to "display" the info in the DB through the browser but the data and text doesn't in fact display. The code in question is here:
print br, 'test';
my $dbh = DBI->connect("DBI:mysql:austinc4", "*******", "*******", {RaiseError => 1} );
my $usersstatement = "select * from users";
my $projstatment = "select * from projects";
# Get the handle
my $userinfo = $dbh->query($usersstatement);
my $projinfo = $dbh->query($projstatement);
# Fetch rows
while (#userrow = $userinfo->fetchrow()) {
print $userrow[0], br;
}
print 'end';
This code is in an if statement that is surrounded by the print header, start_html, form, /form, end_html. I was just trying to debug and find out what was happening and printed the statements test and end. It prints out test but doesn't print out end. It also doesn't print out the data in my DB, which happens to come before I print out end.
What I believe I am doing is:
Connecting to my DB
Forming a string the contains the command/request to the DB
Getting a handle for my query I perform on the DB
Fetching a row from my handle
Printing the first field in the row I fetched from my table
But I don't see why my data wouldn't print out as well as the end text. I looked in DB and it does in fact contain data in the DB and the table that I am trying to get data from.
This one has got me stumped, so I appreciate any help. Thanks again. =)
Solution:
I was using a that wasn't supported by the modules I was including. This leads me to another question. How can I detect errors like this? My program does in fact compile correctly and the webpage doesn't "break". Aside from me double checking that all the methods I do use are valid, do I just see something like text not being displayed and assume that an error like this occurred?
Upon reading the comments, the reason your program is broken is because query() does not execute an SQL query. Therefore you are probably calling an undefined subroutine unless this is a wrapper you have defined elsewhere.
Here is my original posting of helpful hints, which still apply:
I hope you have use CGI, use DBI, etc... and use CGI::Carp and use strict;
Look in /var/log/apache2/access.log or error.log for the bugs
Realize that the first thing a CGI script prints MUST be a valid header or the web server and browser become unhappy and often nothing else displays.
Because of #3 print the header first BEFORE you do anything, especially before you connect to the database where the script may die or print something else because otherwise the errors or other messages will be emitted before the header.
If you still don't see an error go back to #2.
CGIs that use CGI.pm can be run from a command line in a terminal session without going through the webserver. This is also a good way to debug.