I am trying to click a button inside an iframe using pyppeteer - the python version of puppeteer
However, I have drawn a blank. A simple page.click('#selector') does not seem to draw results and await page.waitForSelector('#selector') does not pick it up either
Could anyone advise?
The buttons prior to the iframe work fine
Thanks
You need to switch the context to iframe.
There's an example in other thread: Trying to click a button within an iframe with puppeteer
And there's a solution from pptr docs (probably they're similar to python): https://pptr.dev/#?product=Puppeteer&version=v9.0.0&show=api-class-frame
Related
I'm embedding various content from Issuu on a web page. On page load the embedded content from Issuu is automatically in focus, with visible menus and shadows within the embedded iframe.
This seems to be the standard solution, and there's no way to prevent this with the given embed codes from Issuu. But I would really like to find a way to load the content without it being in focus before the user actually hovers/clicks the embedded area.
As of now the initial focus is only removed if I first click somewhere within the embedded content, and then move my pointer outside of the content.
Is there any way to sort this out with the help of jQuery?
I have tried to solve this by adding the following jQuery code:
$('#issuu_embed').blur();
I also tried to simulate a click on the embedded iFrame, in an attempt to replicate the behaviour mentioned above.
But neither does the trick, and I assume it takes a slightly more sophisticated piece of code to make this work.
Grateful for any hints that could point me in the right direction.
Live CodePen:
https://codepen.io/ehrogn/pen/PoEmJKv
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 :|)
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.
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();
I would like make a script for Greasemonkey (GM),that find and navigate in a link embed in a flash element.
I think that is possible to make it to work with function .click() ,but won't work :(
Here's the source code of the page that contains flash elements..
Source code
Is possible to make that to work?
Thanks in advance.
LUCA.
Flash runs inside of a plugin within the browser, so from an external code point of view it's a black box. The only way to be able to programatically access a link embedded within a Flash element is to have the Flash object pass the link to your script via loadvars.