A specific page in the site I am testing have few buttons that wont register any clicks via selenium Webdriver or manual clicks while opened with chrome binary driver. It works fine while I manually test it in chrome browser.
I tried adding waits, javascript click, action click for selenium with no success.
Webdriver is not throwing an error for clicking/finding element as its doing as it supposed to (I think) but since the page is not responding and not moving forward to the next, I am getting a page object error
Hard to help without specific details, but here's my best attempt:
Potential Problem 1. Make sure the element is not on an iframe, if so here's a link explaning how to fix your code:
How to switch frames - Selenium - Java
Potential Problem 2. Open an incognito/alternate tab, access the same page and check that the CSS Selector/X-Path you are using is existent and pointing to the correct element. If that is not the case, try to correct it by looking at the classes that did not change from the previous Selector to the new.
Related
Please I am not sure what I have done wrong. On the first page I have my code run the following:
next = self.driver.find_element_by_name("checkout_shipping")
actions = ActionChains(self.driver)
actions.move_to_element(next)
actions.click(next).perform()
after clicking next, I want my code to click deliver on the second page:
deliver = self.driver.find_element_by_name("final_shipping_option")
actions_check = ActionChains(self.driver)
actions_check.move_to_element(deliver)
actions_check.click(deliver).perform()
However the second page loads and does nothing. On terminal I get "Process finished with exit code 0" as though everything worked fine when it didn't.
Selenium is a Library that essentially acts as a user. So it loads pages on a browser and manually preforms a click.
I believe your script is finding the correct Element with name "final_shipping_option" but maybe it clicks it too fast for the browser since it's still loading in the Webpage.
Consider trying a time.sleep(x) or something like this:
Wait until page is loaded with Selenium WebDriver for Python
Another possibility is that the name of the element is incorrect, so you're clicking the wrong element? Try to click it via ID, or Class or even XPATH depending on if the page is very dynamic or not..
I use a userscript to modify the client-side code of a website. This code is adding an anchor tag to the page. Its target is _blank. The thing is that if I click this link too frequently, the site errors. A simple refresh on the new tab fixes the problem.
When I click on the link and it instantly opens a new tab. But I don't want that new tab to render until I visit it, or with some sort of time delay. Is there a way of achieving this?
I am using Firefox, so Firefox-only solutions are fine. I found this, but I don't see a way of using it to prevent the tab from rendering in the first place. When I Google for this, I see results about add-ons that can solve the problem. But, the links to them always 404. Ideally, the solution would only affect the tabs created by this script instead of the way all tabs work, but if the only way to do it is to affect the way all tabs work, I'd accept that as a solution.
The Tampermonkey documentation says there is a GM_openInTab function. It has a parameter called loadInBackground, but it only decides if the new tab is focused when you click the link.
If there is a way of making this new tab render some HTML of my choosing, I think that would be a neat solution. i.e., I'd write some HTML that, on focus, goes to the actual website's page. If this is an option, I'd need to know how to open a tab to HTML of my choosing in grease monkey.
(Just realization of idea you told in your question yourself)
You can place simple page that waits for focus and then redirects to what you pass in URL parameter somewhere and open in background tabs. Like:
load-url-from-search-on-focus.html?http://example.com:
<!doctype html>
<body
onload="document.title=u=location.search.slice(1)"
onfocus="u?document.location.replace(u):document.write('?search missing')">
Try it.
(data:uri could have been used instead of hosted page, if there weren't those pesky security precautions blocking rendering of top-level datauri navigations :|)
I've done some looking around and couldn't find any solution to this problem.
I'm creating a Chrome extension, with a manifest that points to the opening file home-times.html. This works, though I want to redirect it internally to the other page home-welcome.html inside the extension so it loads another page INSIDE the extension.
I've read a lot of questions that refer to changing the current tab's page, though that's not what I am after.
Tests
By using the following code:
test
Opens a new tab, with the extensions page that I am trying to access in that new tab.
If I got you right, you want to change your popup innerHTML, in this case I suggest using jQuery, to change original file to the result you want.
If you just want to open new tab, with your home-welcome.html, you can do this, in your popup.js :
window.open('home-welcome.html','_blank')
If none of this is what you are looking for, can you please provide an example, I will try to help.
I am using Selenium and java, after clicking on one button I land on another page and I see the input tag that I am looking in the viewport
after waiting for page to load with
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
in order to get the tag I use the scrollIntoView() and search for the element by id using javascript inside java this way:
js.executeScript("document.getElementById('elementId').scrollIntoView(true);");
but the problem is that document.getElementById('elementId') returns null; I tried it also in the firefox webdriver console with the same result.
If I execute document.getElementById('elementId') on the same page using firefox console but without using Selenium webdriver I get the tag as expected.
Why am I getting this null using Selenium? How to fix it?
Please use the below code before the scrollIntoView() code
driver.switchTo().frame(driver.findElement(By.tagName("iframe")));
IF any element resides under iframe tag you should switch your driver to iframe using above
If you need to switch your driver in default mode then u need to use below code
driver.switchTo().defaultContent()
If the element is under modal then use it
driver.switchTo().frame("ModelFrameTitle");
or
driver.switchTo().activeElement()
I am currently working on testing a site and one of the issues I am running into is working with a non Javascript popup.
I have tried using the Selenium Alert interface.
Sample of what I have done
Alert a = WebDriver.switchTo().alert()
alert.accept()
alert.dismiss()
This seems to work for Javascript pop up alerts but not for non javascript pop up alerts. Is there any way to deal with pop ups with Selenium that aren't Javascript based?
Last time I ran into a pop-up like this, it was a frame that was otherwise "invisible." Open the page with your favorite browser, highlight something in the pop-up, right-click it and choose Inspect Element, then follow its XPath. You may have to switch frames a few times in Selenium to get where you need to be.
If its HTML popup then no specific thing needs to be done, just locate required element normally just like you do for normal web page.
But if its saying element not found then there can be 2 cases:
popup is present inside an iframe
before this popup you were inside iframe but that pop up is present in defaultContent View.
Depending on case, use these solutions:
For #1 : driver.switchTo().frame(0); //Here 0 means first iframe, you can use iframe id also
For #2 : driver.switchTo().defaultContent();