How can I get the network-"Status" of an webelement? - java

i am using Selenium Webdriver on Java and I am trying to get the network status of every element with a network status like you can see in the image below.
Is there any way to get the status?
Edit:
I guess I cannot upload images. If you press F12 to open the dev-tools there is a network menu. If you click on it, the status of every webelement will show up there.

AFAIK DevTools and Networking tab controls are not natively supported by Selenium.

Related

How to attach a chrome window to a desktop application Selenium?

My problem is when I click on a desktop icon, it opens a link in already opened chrome browser in a new tab. How do I attach with the already opened browser and not a new one?
The below code returns a null because there is no window opened through selenium ofcourse, so yeah.
Set<String> windows = webdriver.getWindowHandles();
System.out.println(windows);
Any suggestions would be of great help. Thanks In advance.
There is no way to attach the chrome window that you've opened from the desktop application to your WebDriver instance.
If you want to be able to control a web page with a Selenium - you must pass your URL to a driver like that:
webdriver.get("https://www.your_link.com");
You might think about the way of getting and storing your URL as a variable and passing it into your code.
That would also be helpful if you add a bit more details about the problem. It's a bit unclear at what stage of the test you open the web page with a desktop application. Selenium can't be used to test desktop applications. Code sample of the test from your project would also help.

Clear Network tab using Selenium Java

I am trying to load a page, and I am automating the process of checking for a POST request after a button is clicked.
In order to do this, I need to clear the Network tab of all previous entries before the button is clicked, otherwise it will not show up on the list for some reason.
Is there a way to do this via logging or some other means in Selenium Java?
As far as I know, there is no way to interact with Chrome's dev tools as you intent to. Alhough, if you are interested in obtaining/parse data from the Network tab in Chrome you can do that following their quick tutorial in their website here.
I don't know what is you idea but here I leave you 2 cents.
Perhaps you could access this data and work it elsewhere instead of constant refreshing.
Here is a similar question to yours.

Selenium - Internet explorer - Java - How to disable images loading?

To improve the performance of the automation, trying to disable image loading.
I found a way to do it in Firefox & Chrome (Ref: Selenium WebDriver/Firefox|Chrome/Java How to disable image loading), not Internet Explorer. Please help me out here.
Below is the answer, received from Selenium team.
Ref: https://github.com/SeleniumHQ/selenium/issues/7512
This isn’t possible without changing the browser configuration/profile, and IE does not support profiles outside the currently logged in Windows user account. The driver will not be modified to change the configuration, since there is no guaranteed way to revert the configuration change after the session ends. You can either manually set the browser configuration in the options dialog (if such a setting exists), manipulate the setting programmatically using the Windows registry (assuming such a setting exists for IE), or use a web proxy to block retrieval of images. This is not a feature the driver will be implementing.
To improve the performance of the automated program disableing the image loading within internetexplorer you need to modify the data for the name Display Inline Images within HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main through the Registry Editor as no as follows:
Value name Value data
--------------------- ----------
Display Inline Images No
Snapshot:
To disable the images while browsing on Internet Explorer, you could open the Internet Options and go to the Advanced Tab. Scroll down to Multimedia Section and uncheck Show Pictures check-box, click Apply and Exit.

Selenium click chrome physical buttons like menu, left, right navigation, bookmarks

I'm working on a some automation work, as per my requirement I need to click on Chrome Physical buttons like left nav, right nav, bookmarks, menu etc. I can do with shortcuts but my requirement is to click on browser buttons. Any ideas would be helpful. Thanks in advance.
As per your question you want to click on Chrome Physical buttons like left navigation, right navigation, bookmarks, menu etc.
But if you look into the documentation in Selenium Home Page it clearly mentions that :
The entire suite of tools provided by Selenium results in a rich set of testing functions specifically geared to the needs of testing of web applications. These operations allow many options for locating UI elements and comparing expected test results against actual application behavior.
So factually Selenium by design interacts with the HTML DOM and the WebElements located in the DOM Tree
Now the desired controls e.g. left navigation, right navigation, bookmarks, menu are out of the DOM. Hence you cannot mock the click on those controls.
However all the Selenium Language Binding Art provides a handfull of methods to achieve the same result. Here are a few from the Selenium Python Binding Art :
Maximize : To maximize the browser window.
driver.maximize_window()
Minimize : To minimize the browser window.
driver.minimize_window()
Close : To close the browser window.
driver.close()
Quit : To close the browser window gracefully.
driver.quit()
Refresh : To refresh the url.
driver.refresh()
Forward : To move forward.
driver.forward()
Back : To move backwards.
driver.back()
And of-coarse Get : To invoke an url.
driver.get('http://google.com/')
There are functions for this that is built-in:
driver.forward()
driver.back()
https://selenium-python.readthedocs.io/navigating.html#navigation-history-and-location
It doesn't appear that selenium can interact with the Bookmark, but let me check some more.
This can't be done with selenium webdriver and I think also not with the standalone selenium server. Selenium only allows to interact with the DOM.
The only way to achieve what you want to do is to use an automation tool that actually runs directly in the OS that you use. Java can be used to write such a program.
I would however recommend to not go this route. Instead try to convince whoever is responsible for your requirements to re-think and allow to use other means of achieving back and forward actions.

Selenium Web Driver click action

I have a code in selenium which dynamically clicks on the tabs in menu page. And sometimes happens that tab is not clickable(it is just a plain td with span inside) and when Web Driver tries to click on this tab, my program gets frozen (no exception thrown or anything).
I can't avoid clicking on tabs like that but I would like to somehow prevent that freeze after click. So can I set some timeout or tell to selenium what to do if element is not clickable?
driver.findElement(By.xpath(
format("//span[#class='rf-tab-lbl'][text()='{0}']",
navigation.getGroup()))).click();
//if the tab is currently selected (hence is not clickable) selenium won't click
// on it and program freezes
Please try another page from a different website. It might be a JS looping issue.
I encountered such an issue in HtmlUnit for some URLs.
I raised issue in HtmlUnit user group.
They told me that JS infinite loop was causing freez.
Time out did not work for me as well.
I tried to apply my own time out. That did not work too.
Refer following question for applying own timeout
HtmlUnit WebClient Timeout
If it works for another website, problem might be site specific.
You can attach source of Selenium in eclipse and check / debug where it is getting stuck.
I did same for HtmlUnit. I reached to parse method, which did not come out.
If still does not work, contact Selenium support.

Categories

Resources