Select parent element of known element in Selenium

There are a couple of options there. The sample code is in Java, but a port to other languages should be straightforward. Java: WebElement myElement = driver.findElement(By.id(“myDiv”)); WebElement parent = (WebElement) ((JavascriptExecutor) driver).executeScript( “return arguments[0].parentNode;”, myElement); XPath: WebElement myElement = driver.findElement(By.id(“myDiv”)); WebElement parent = myElement.findElement(By.xpath(“./..”)); Obtaining the driver from the WebElement Note: As you can … Read more

Why does appending a to a dynamically created seem to run the script in the parent page?

Had the same problem, took me hours to find the solution. You just need to create the script’s object using the iframe’s document. var myIframe = document.getElementById(“myIframeId”); var script = myIframe.contentWindow.document.createElement(“script”); script.type = “text/javascript”; script.src = src; myIframe.contentWindow.document.body.appendChild(script); Works like a charm!

How can I return to a parent activity correctly?

You declared activity A with the standard launchMode in the Android manifest. According to the documentation, that means the following: The system always creates a new instance of the activity in the target task and routes the intent to it. Therefore, the system is forced to recreate activity A (i.e. calling onCreate) even if the … Read more

Python subprocess get children’s output to file and terminal?

The call() function is just Popen(*args, **kwargs).wait(). You could call Popen directly and use stdout=PIPE argument to read from p.stdout: #!/usr/bin/env python import sys from subprocess import Popen, PIPE from threading import Thread def tee(infile, *files): “””Print `infile` to `files` in a separate thread.””” def fanout(infile, *files): with infile: for line in iter(infile.readline, b””): for … Read more

How to get parent process in .NET in managed way

Here is a solution. It uses p/invoke, but seems to work well, 32 or 64 cpu: /// <summary> /// A utility class to determine a process parent. /// </summary> [StructLayout(LayoutKind.Sequential)] public struct ParentProcessUtilities { // These members must match PROCESS_BASIC_INFORMATION internal IntPtr Reserved1; internal IntPtr PebBaseAddress; internal IntPtr Reserved2_0; internal IntPtr Reserved2_1; internal IntPtr UniqueProcessId; … Read more

How may I reference the script tag that loaded the currently-executing script?

How to get the current script element: 1. Use document.currentScript document.currentScript will return the <script> element whose script is currently being processed. <script> var me = document.currentScript; </script> Benefits Simple and explicit. Reliable. Don’t need to modify the script tag Works with asynchronous scripts (defer & async) Works with scripts inserted dynamically Problems Will not … Read more