How to implement random select and click from the list (Android / Appium) - automation

I was trying to create an automated testing with a requirement to random select from the given list (with different urls) tried some of the script available online however cant make it to work and getting ElementNotFound. Please help me on this
List elementList = driver.findElements(By.xpath("//android.view.View[#content-desc = 'carouselItem']"));
Random rand = new Random();
int index = rand.nextInt(elementList.size()-1);
elementList.get(index).click();
enter image description here

Related

Rest API Pagination Query (List. Generate) in Power query/Power BI

I . sorry for posting this second or third time but couldn't find any solutions from the community. let me know if some who can help me out. Any power query expert here with Rest API's who can help me with List. Generate function query for pagination?
Issue: Pagination of API URL that allows 50 rows of data per Agent.
URL: https://vcc-na4.8x8.com/api/stats/agents/{Agent-ID}/Activities?n=1
Background: Created a function below which allows me to extract all Agent ID's(But only 50 rows per ID).
(id as text, n as number) as table=>
let
Source = Xml.Tables(Web.Contents("https://vcc-na8.8x8.com",
[RelativePath="/api/stats/agents/" &(id)&"/activities?n="&number.totext(n) ) ),
in
Source
Than a created a query below to extract all the rows as well watching curbal's video,
Video Link: https://www.youtube.com/watch?v=05yhwnuCjRw
Query:
let
Source = List.Generate(()=>
[result = try all_rows (1) otherwise try null, n=1],
each [result]<> null,
each [result = try all_rows ([n]+50) otherwise null, n=[n]+50],
each [result]
)
in
Source
but it shows this error,
enter image description here

NASA API into table in excel

I'm trying to download weather related data using the Nasa API into excel using powerquery.
I'm trying to query wind speed at 50 metres, the string for which is
https://power.larc.nasa.gov/cgi-bin/v1/DataAccess.py?&request=execute&tempAverage=DAILY&identifier=SinglePoint&parameters=WS50M&userCommunity=SB&lon=142&lat=-38&startDate=20170101&endDate=20201231&outputList=JSON&user=DOCUMENTATION
I know this is the correct string because when I paste this as a url into my chrome browser, I get the desired output in JSON. However, when I try to get the output into a table in excel, I get a mere 2 records. Something is clearly amiss.
Any help on this will be appreciated.
Olá, utilize o power Query do excel.
let
Fonte = Json.Document(Web.Contents("https://power.larc.nasa.gov/cgi-bin/v1/DataAccess.py?&request=execute&tempAverage=DAILY&identifier=SinglePoint&parameters=WS50M&userCommunity=SB&lon=142&lat=-38&startDate=20170101&endDate=20201231&outputList=JSON&user=DOCUMENTATION")),
features = Fonte[features],
features1 = features{0},
properties = features1[properties],
parameter = properties[parameter],
WS50M = parameter[WS50M]
in
WS50M

How to use Bioproject ID, for example, PRJNA12997, in biopython?

I have an Excel file in which are given more then 2000 organisms, where each one of them has a Bioproject ID associated (like PRJNA12997). The idea is to use these IDs to get the sequence for a later multiple alignment with other five sequences that I have in a text file.
Can anyone help me understand how I can do this using biopython? At least the part with the bioproject ID.
You can first get the info using Bio.Entrez:
from Bio import Entrez
Entrez.email = "Your.Name.Here#example.org"
# This call to efetch fails sometimes with a 400 error.
handle = Entrez.efetch(db="bioproject", id="PRJNA12997")
I've been trying, and Entrez.read(handle) doesn't seems to work. But if you do record_xml = handle.read() you'll get the XML entry for this record. In this XML you can get the ID for the organism, in this case 12997.
handle = Entrez.esearch(db="nuccore", term="12997[BioProject]")
search_results = Entrez.read(handle)
Now you can efecth from your search results. At this point you should use Biopython to parse whatever you will get in the efetch step, playing with the rettype http://www.ncbi.nlm.nih.gov/books/NBK25499/table/chapter4.T._valid_values_of__retmode_and/
for result in search_results["IdList"]:
entry = Entrez.efetch(db="nuccore", id=result, rettype="fasta")
this_seq_in_fasta = entry.read()

Select specific elemets from a website in VB.net (WebScraping)

I found a website where I can look up vehicle inspections in Denmark. I need to extract some information from the page and loop through a series of license plates. Lets take this car as an example: http://selvbetjening.trafikstyrelsen.dk/Sider/resultater.aspx?Reg=as87640
Here on the left table, you can see some basic information about the vehicle. On the right, you can see a list of the inspections for this specific car. I need a script, which can check if the car has any inspections and then grab the link to each of the inspection reports. Lets take the first inspection from the example. I would like to extract the onclick text from each of the inspections.
The first inspection link would be:
location.href="/Sider/synsrapport.aspx?Inspection=18014439&Vin=VF7X1REVF72378327"
or if you could extract the inspection ID and Vin variable from the URL immediately:
Inspection ID: 18014439
Vin: VF7X1REVF72378327
Here is an example of a car which don't have any inspections yet, if you want to see what that looks like: http://selvbetjening.trafikstyrelsen.dk/Sider/resultater.aspx?Reg=as87400
Current Solution plan:
Download the HTML source code as a String in VB.net
Search the string and extract the specific parts.
Store it in a StringBuilder and upload this to my SQL server
Is this the most efficient way, or do you know of any libraries which is used to specific extract elements from a website in VB.net! Thanks!
You could use Java libraries HtmlUnit or Jsoup to webscrape the page.
Here's an example using HtmlUnit:
LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);
java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF);
WebClient client = new WebClient(BrowserVersion.CHROME);
client.getOptions().setJavaScriptEnabled(true);
client.getOptions().setThrowExceptionOnScriptError(false);
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
HtmlPage page = client.getPage("http://selvbetjening.trafikstyrelsen.dk/Sider/resultater.aspx?Reg=as87640");
HtmlTable inspectionsTable = (HtmlTable) page.getElementById("tblInspections");
Map<String, String> inspections = new HashMap<String, String>();
for (HtmlTableRow row: inspectionsTable.getRows()) {
String[] splitRow = row.getAttribute("onclick").split("=");
if (splitRow.length >= 4) {
String id = splitRow[2].split("&")[0];
String vin = splitRow[3].replace("\"", "");
inspections.put(id, vin);
System.out.println(id + " " + vin);
}
}

Pull info from datapool, increment a value and store the datapool

The application I test has some areas where it requires unique data. Specifically, the application will generate a request number that can only be used once. After my test runs I must manually update my datapool reference for this number. Is there any way using java, that I can get the information stored in my datapool, increase the value by one, and then save the data back to the datapool. This way I can keep rft in sync with my application in regard to this number.
Here is an example how to read a value from the datapool, increment it by 1, and save it back to the datapool. It is an adapted example from the book Software Test Engineering with IBM Rational Functional Tester. The original source code is from chapter 5 (and can be downloaded from the book's homepage).
// some imports
import org.eclipse.hyades.edit.datapool.IDatapoolCell;
import org.eclipse.hyades.edit.datapool.IDatapoolEquivalenceClass;
import org.eclipse.hyades.execution.runtime.datapool.IDatapool;
import org.eclipse.hyades.execution.runtime.datapool.IDatapoolRecord;
int value = dpInt("value");
value++;
java.io.File dpFile = new java.io.File((String) getOption(IOptionName.DATASTORE), "SomeDatapool.rftdp");
IDatapool dp = dpFactory().load(dpFile, true);
IDatapoolEquivalenceClass equivalenceClass = (IDatapoolEquivalenceClass) dp.getEquivalenceClass(dp
.getDefaultEquivalenceClassIndex());
IDatapoolRecord record = equivalenceClass.getRecord(0);
IDatapoolCell cell = (IDatapoolCell) record.getCell(0);
cell.setCellValue(value);
DatapoolFactory factory = DatapoolFactory.get();
factory.save((org.eclipse.hyades.edit.datapool.IDatapool) dp);
I think it is quite a lot of code to simply change one value—maybe it is easier to use some other method like writing the value to a normal text file.