I am trying to switch to the previous frame.
In my code
I switch to a frame (BRCT1Frame),
Click a button that opens a new window
Switch to a new window
Switch to the frame inside of the window
Insert data & save which closes both the window and frame
However, there is a frame that is before the BRVT1Frame that I need to switch to.
Here is My Code:
BRT1Frame=driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))
buttons=driver.find_elements_by_css_selector("button")
for button in buttons:
if button.text.strip()=="Create Community":
button.click()
#A new pop up window causes me to switch windows
for handle in driver.window_handles:
BRT=driver.switch_to_window(handle)
print(BRT)
#then I switch frames
driver.switch_to_frame(driver.find_element_by_class_name("FormDialogIFrame"))
driver.find_element_by_id("CommunityFormCommunityNameTextBox").send_keys("1st MEB STAFFEX")
save=driver.find_element_by_id("CommunityFormSaveButton").click()
#that popup closes now I have to switch to another frame
The frame I am trying to switch to code:
<iframe role="presentation"
class="x-component x-window-item x-component-default"
src="/brvt?lang=en_US&owf=true&themeName=a_default&
themeContrast=standard&themeFontSize=12"
name="{"id":"778a1259-bc80-602e-c0ad-16a3f9220516","containerVersion":"7-GA","webContextPath":"/owf","preferenceLocation":"https://www.url,com;,"relayUrl":"https://url.com/55js/even/rpc_relay.uncompressed.html","lang":"en_US","currentTheme":{"themeName":"a_default","themeContrast":"standard","themeFontSize":12},"55f":true,"layout":"desktop","url":"/brvt","guid":"260f0022-66de-a78b-3ce8-8de63a3bdbec","version":1,"locked":false}"
id="{"id":"778a1259-bc80-602e-c0ad-16a3f9220516"}"
frameborder="0"></iframe>
I have tried to do this:
driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))
this worked but when I tried to click a drop down menu inside of the frame:
driver.find_element_by_css_selector("#OYk3vd6NKj1jbrnew > td.sub_item_text").click()
I have also tried:
driver.switch_to_frame(driver.find_element_by_id("{"id":"778a1259-bc80-602e-c0ad-16a3f9220516"}")
I get an error that states that it is unable to locate the element.
Suggestions?
If you just want to locate exact frame that you specified, then try:
required_frame = driver.find_element_by_xpath('//iframe[#role="presentation"]')
driver.switch_to_frame(required_frame)
or even more specific:
required_frame = driver.find_element_by_xpath('//iframe[#role="presentation"][#class="x-component x-window-item x-component-default"]')
driver.switch_to_frame(required_frame)
Does this advise was helpful?
Related
I am fairly new to PyQt5. So here, I am trying to work on a project in which first window in login page dialog window. So if password entered are correct it will open another window.
def login(self):
eid=self.lineEdit.text()
epass=self.lineEdit_2.text()
if eid==idd and epass==passs:
from BloodBank import Ui_MainWindow
self.MainWindow = QtWidgets.QMainWindow()
self.ui = Ui_MainWindow()
self.ui.setupUi(self.MainWindow)
LoginPage.hide()
self.MainWindow.show()
else:
self.msgdlg("Wrong ID or Password!")
In this Window, from title bar menu action, I tried to attach yet another window, which when opened, current window become hidden. For this I wrote following code:
def menu(self,action):
txt=(action.text())
if txt=="Blood":
try:
from Blood import Ui_MainWindow
self.MainWindow1 = QtWidgets.QMainWindow()
self.ui = Ui_MainWindow()
self.ui.setupUi(self.MainWindow1)
MainWindow.hide()
self.ui.updatelist()
self.MainWindow1.show()
except Exception as e:
print(e)
Now, When I run above code without MainWindow.hide() it run perfectly fine. But as soon as I feed MainWindow.hide() it gives following error.
name 'MainWindow' is not defined
When I try same .hide() funtion with login page, it works.
What do I need to do so I can hide my window?
Your code is a bit unclear, but i think it should be self.MainWindow.hide() because we are trying to hide our parent widget.
Edit
Try self.hide() in the bloodbank file instead of MainWindow.hide() I am assuming that in the file bloodbank you have your mainwindow.
Here is the problem, you have two files the Login File which consists of the loginpage and the bloodbank file.
when you created a the instance of self.MainWindow it is only in the namespace of the loginpage.
And you try to open a another window from this file (which is the 2nd part of your code). MainWindow instance is not present because you have defined (instantiated) in another file (login page).
i've got a site with a lot of phone models, but the code is originally from another part of the site, where the mobiles are only shown when you click on the box, but for this part of the site, I want the mobiles to be shown at anytime, so how do i make this div
<div class="submit_filter ans_div" style="display: table;"></div>'
into something that just shows without a click?
The site url are www.findaphone.dk/mobiler
And as you see, right now there is a big box at the top of the site you have to click on.
Thanks in advance!!
The JavaScript for this click event is at line 620 of your source code. CTRL+F to find it, it looks like this:
$(document).on('click','.submit_filter',function () {
Right now, the line is waiting for a click event on that large button (.submit_filter) before executing the code. Replace the line above with this, and the code in that function will trigger on document ready (when the page loads):
$(document).ready(function () {
I use a button in my header of my website to remove one movieclip (page of my website) off the stage and tweened another onto the page like so...
function moviesClick(event:MouseEvent):void
{
pageContainer_mc.removeChildAt(1);
pageContainer_mc.addChild(pMov);
TransitionManager.start(pageContainer_mc, {type:Photo, direction:Transition.IN, duration:1, easing:None.easeNone});
}
I have encountered a problem - if i have been on this timeline previously and gone from frame 1 to say frame 2 (another page in that area of my website) when i use the button in my head of my website again, i stay on frame 2 but i want to be returned to frame 1 always when this button is pressed (code above for my button).
How do i force this timeline to start at frame 1 whenever the button in my header (on a seperate timeline) is pressed?
Is the timeline in question the pagecontainer_mc? If so:
pageContainer_mc.gotoAndStop(1);
Edit based on comment discussion:
Assuming that's the correct path, this should work.
moviesPage.moviesHolder.moviesNow.gotoAndStop(1);
I want to flip through a notebook, without using any buttons or something like that, but actually clicking on the active element of the page or by dragging the page to get to the next one. The notebook is something similar to this one. I tried many different approaches but failed.
The code I am trying to get to work is:
WebElement page= driver.findElement(By.xpath("//*[#id='pages']/section[4]/div"));
Actions kkk = new Actions(driver);
Actions flip= kkk.moveToElement(page, 780, 200);
flip.click().build().perform();
I also tried the next approach :
flip.perform();
Thread.sleep(200); //to allow the mouse to hover and activate the page
flip.click().perform();
Nothing works, the mouse hovers over the neccesary place and if I try to click in the same place, it just resets and the page rolls back flat.
Also, is there any way finding the neccesarry place (the active spot of the element) without using Offset (coordinates), I can't think of any other way.
This seems more on the lines of drag and drop.
Try doing something like this
WebElement draggable = browser.findElement(By.xpath("//*[#id='pages']/section[4]/div"));
new Actions(browser).dragAndDropBy(draggable, 200, 10).build().perform();
Based on
org.openqa.selenium.interactions.Actions.dragAndDropBy(WebElement source, int xOffset, int yOffset)
UPDATE
or this way
WebElement element = driver.findElement(By.name("source"));
WebElement target = driver.findElement(By.name("target"));
(new Actions(driver)).dragAndDrop(element, target).perform();
UPDATE 2
Or this way
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(someElement)
.moveToElement(otherElement)
.release(otherElement)
.build();
dragAndDrop.perform();
This is probably going to be a simple question, but I can't seem to find my answer online after searching.
I am using the following simple code:
var fileReferenceList:FileReferenceList = new FileReferenceList();
fileReferenceList.addEventListener(Event.SELECT, onSelect);
fileReferenceList.browse();
A big flash button triggers this code, which works perfectly fine. Unfortunately, I don't enforce that the button cannot be clicked while the dialog box to browse file is opened, so I get "Error: Error #2041: Only one file browsing session may be performed at a time." if I click on the button while the pop up dialog box is up.
A solution that I really like is the one that Google Docs has. It does not let you click on their button, above "Select files to upload" while the pop up dialog box is showed. Actually, this dialog box has a sort of priority: You can't click ANYWHERE on the page before you select files or cancel on this dialog box.
I would like to have the same behavior, not let the users click anywhere in my web page until this dialog box is done, just like Google Docs does it, but I can't seem to find how.
Any clue from anyone please?
Thank you very much,
Rudy
You should take a look at the HTML file that embeds the SWF. In Windows/Firefox, the behavior of the "select file" dialog will differ depending on what Window Mode (wmode) you use in the EMBED tag in the HTML page.
If you use wmode="opaque" or wmode="transparent", then the "select file" dialog will not be modal, and you'll be able to click on the browser window itself to bring it to the foreground. (Also, you'll be able to minimize and even the browser window). This only seems to apply to Windows/Firefox; other browsers all appear to keep the "select file" dialog on top.
If you omit the wmode attribute (it defaults to "window"), or set it to "direct" or "gpu", then the "select file" dialog will be modal.
Modal "select file" dialog:
<embed src="Upload.swf"
wmode="window"
quality="best"
scale="noscale"
swliveconnect="true"
salign="lt"
width="220" height="75" bgcolor="#ffffff"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
Non-modal "select file" dialog:
<embed src="Upload.swf"
wmode="opaque"
quality="best"
scale="noscale"
swliveconnect="true"
salign="lt"
width="220" height="75" bgcolor="#ffffff"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
The Google Docs browse dialog is "modal" (meaning the focus can't go to anything else while the dialog is up). As far as I can tell, the FileReference dialog box should be modal by default. What browser are you testing this in?
As a workaround, you could put a transparent (or semi-transparent, for a dimming effect) overlay over the entire stage while the dialog is up. This won't prevent the focus changing, but it will prevent other buttons on the stage from being clicked. For example a class like this:
public class Overlay extends Sprite
{
private static const BACKGROUND_OPACITY:Number = 0.40;
public function Overlay(_stage:Stage)
{
graphics.beginFill(0x000000, BACKGROUND_OPACITY);
graphics.drawRect(0, 0, _stage.stageWidth, _stage.stageHeight);
graphics.endFill();
}
}
That would be used like this (from the document class):
private var overlay:Overlay;
public function onButtonClick(e:MouseEvent):void
{
overlay = new Overlay(stage);
stage.addChild(overlay);
// ...
fileReference.browse();
// ...
}
public function onSelect(e:Event):void
{
stage.removeChild(overlay); // Also do this on cancel, and on errors
}