Categories
discuss

Is creating the following for loop bad for Garbage Collection?

I have an update Method, that updates the level in the game every ms. Inside this method, i have several for loops that look like this:

for (int i = 0: i < 10; ++i){

}

When i say:

int i = 0

Does that create a lot of garbage? And would there be an alternative?

Thank you

Answer

When you write int i = 0 it creates no garbage.

The variable i has type int which is a primitive type, not an object (or reference) type. The state of i is held entirely within the stack frame of the enclosing method; i.e. not on the heap.

Does that create a lot of garbage?

No.

And would there be an alternative?

No alternative is necessary …

Categories
discuss

How to click on hidden element in Selenium WebDriver?

I have a grid which displays some records. When I click on a record and inspect that element it is shown that it is hidden but it is visible in the grid.

My HTML is:

<a href="http://192.168.1.6/eprint_prod_3.8/settings/othercost_add.aspx?type=edit&id=805" title="Plastic Spiral Bind"
<div style="float: left; width: 99%; overflow: hidden; height: 15px; overflow: hidden"> Plastic Spiral Bind </div>
</a>

The above code is hidden while inspecting but it is visible in grid.

Selenium code:

driver.findElement(By.partialLinkText("Plastic Spiral Bind")).click();

Answer

First store that element in object, let’s say element and then write following code to click on that hidden element:

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", element);
Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..