How to capture the status change of a process in selenium after the process is kickstarted Run

0 votes
In my UI, there are status changes likw, once I click on "run".. the status changes like this .."Initialised" ...."Scheduled"..."started" ...."InProgress"..."Passed"/"Failed", How can i capture the status of this dynamically and get the complete stream of status and show to the user like this "Initialized-->Scheduled-->Started-->INprogres-->Passed".

Any refrence links or suggustions please.

The status happens in same element. BUt there is not specific time it takes from one status change to another.
Apr 14, 2020 in Selenium by Jyra
• 580 points
3,219 views
Could you please share the code snippet and error logs if any? It will help in comprehending the issue better.
try{
String strRunstatus = TestExecutionStatus.get(1).getText();
String statusTraverse = null;
if(statusTraverse = null)
statusTraverse 
while(true)
waitMilliSec(2000);
{
if(strRunStatus.equals("Not Started"))
{
statusTraverse = statusTraverse+ "--> " +strRunStatus;
continue;
}
if(strRunStatus.equals("Started"))
{
statusTraverse = statusTraverse+ "--> " +strRunStatus;
continue;
}
if(strRunStatus.equals("Passed"))
{
statusTraverse = statusTraverse+ "--> " +strRunStatus;
break;
}
if(strRunStatus.equals("Failed"))
{
statusTraverse = statusTraverse+ "--> " +strRunStatus;
break;
}
}
What's the error that you are getting?
No elemnt Exception.. BUt is this the correct way @Liana. In debugging, i see that alert box with input textbox with a message in it is acusing exception.
HOw to retrieve text in alert pop-up which is in Input text box. I am able to edit that text box which has message.

You could probably try using prompt for getting user input

var retVal = prompt("Enter your name : ", "your name here");
document.getElementById(formId).submit();

this variable you can access and redirect accordingly

You can store the value of prompt in any control within the form which you can access on the submitted page after the page is submitted.

Thanks Liana, but the alert message which pops up, already has the text in that Input box. I want to capture that text.

this methos is not working. alert.getText().

In case you're trying to automate this using the JavaScript alert() function, the following code could help.

// Switch the driver context to the alert
Alert alertDialog = driver.switchTo().alert();

// Get the alert text
String alertText = alertDialog.getText();

// Click the OK button on the alert.
alertDialog.accept();
This is not working.

Check this out. 

https://www.edureka.co/blog/alerts-popups-in-selenium#How_to_handle_alerts_in_Selenium_Webdriver?

The last part of this blog that deals with integrated approach of dealing with popup alerts might help!

1 answer to this question.

0 votes
Best answer

For your requirement of capturing and displaying the status dynamically, you could probably try using the xpath.

Your code should be something on these lines:

if (driver.findElements(By.xpath("//span[@ng-bind='scan.scanStatus' and text()='Not Started']")).size()>0)
{
  System.out.println("Status : " + driver.findElement(By.xpath("//span[@ng-bind='scan.scanStatus' and text()='Not Started']")).getText());
  continue;
}

You could develop your code on these lines for implementing the various statuses that you want to display to the user.

Hope this helps!

answered Apr 14, 2020 by Jake George

selected Apr 16, 2020 by Jyra

Related Questions In Selenium

+1 vote
1 answer

How can I automate the process of adding iPhone to cart in Flipkart using Selenium(java),Page Object Model and TestNG? Also validate if product is added and available in cart?

Hey check this https://www.edureka.co/community/47160/automate-purchase-adding-book-cart-flipkart-using-selenium? It deals with a similar ...READ MORE

answered Jan 13, 2020 in Selenium by Karan
• 19,610 points
8,349 views
0 votes
2 answers
+1 vote
1 answer

How to get the HTML source of a webpage using Selenium in Java?

There is a method called getPageSource() in ...READ MORE

answered Jan 11, 2019 in Selenium by Sneha
29,493 views
0 votes
1 answer

How to check the state of a radio button or checkbox in Selenium?

Hey Priya, to check the state of ...READ MORE

answered May 7, 2019 in Selenium by Pratibha
• 3,690 points
4,572 views
0 votes
1 answer

How to run a group of test cases using TestNG in Selenium Webdriver?

Hey Kajal, TestNG allows you to perform ordered ...READ MORE

answered Jun 12, 2019 in Selenium by Abha
• 28,140 points
2,929 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,686 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,149 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,228 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,880 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP