I have a special problem. I made a software in java, what strore informations from a website. But this website shows this data, just if I click a button. It's a simple webdriver problem, but I can click a button only 10 times. It's a very big problem form me, and I cant't do this. :D
The site counts my clicks, if I reach ten clicks, it tells me, I should login. But, it possible to login only with facebook or google account. I don't want to login with facebook or google.
The solution is, I have to close the browser, and I have to reopen that. How can I do this:
driver.close();
driver = new FirefoxDriver();
Okay, but every time when I use this formula, the java code opens a new webdriver. What is the solutin of this problem? Maybe driver.quit(); ??
No!!
If I quit the driver, I can't create a new driver. So, when I open the 321654th webpage, I have 321654/10 webdriver among Windows tasks.
What is the real solution?
Have you tried deleting cookies? You might also then have to refresh the page.
driver.manage().deleteAllCookies()
Try with refresh your page instead of close. Use below code:
driver.navigate().refresh();
Related
enter image description hereHi,Iam new to selenium and java testing. Iam trying to right click on google.com about link and open the link in new window. Up to right click my code works fine. When I send down-arrow nothing happens in the browser. Can anyone tell what's wrong with the code. I have tried it in all different browsers.
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.
I'm trying to write in JAVA some function that can write pin into SSL security pop-up for my automation test. Unfortunately I still don't find solutions. This is an element that Selenium doesn't see. Could anybody help me please?
Selenium can click on web elements in Chrome or WPF elements inside windows applications. The pop up is neither one of them.
You can use the Robot object to type to the keyboard, but you have no way to know when this pop up appears or not. Unless this pop up shows at the exact same time everyday.
Security Warning Window
This image pops up when I click on "Continue to this website (not recommended)."
Please Try This, It works.
public void TestSSLerror() {
//Download IEDriver exe and past in project
driver = new FirefoxDriver();
//Open WebSite for time being let's take http://test.com
driver.get("https://test.com");
//now we are going to use javascipt ,This will click on "Continue to this website (not recommended)" text and will
//push us to the page
driver.navigate().to("javascript:document.getElementById('overridelink').click()");
}
It is better if you can disable the security check by bypassing using required credentials, if it is not related to the test(saves time), otherwise you need to go for a third party tool like auto-it to automate it.
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.