Selenium2: Select option from dropdown causes window to disappear - soap

When I'm using the Select function from Selenium WebDriver, the windows completely disappears, but does stay active (as I can see in the taskbar). So it appears to be minimized, without losing focus.
This is causing certain test to fail.
void select(String locator, String option){
WebElement dropdown = driver.findElement(By.xpath(locator));
Select selectBox = new Select(dropdown);
selectBox.selectByVisibleText(option);
}

Related

MAUI Popups, floating windows and containers

I need to get a popup window that is not bound to the main window but will allow me to determine where on the screen should it appear.
Requirements:
I need to be able to decide the size, and location of the new window even if it's on another screen. (I'm already detecting all the screens so this is not an issue)
I need to be able to operate / change values on the main window while the new window stays in place and receives commands from the changing values on the first window and displays them (Text for example)
The new window should be able to display text but also it would be nice if it would be able to receive a background photo/video.
Is it at all possible in MAUI?
I know how to do that in Windows Forms but it looks like Windows Forms ls out of date and it soon will not be supported.
Also MAUI seems to have a nicer appearance out of the box. I really like it but I'm not sure if what I need to do is doable at the moment?
Yes, you can use Multi-window support in MAUI as Jason suggested.
You can call an Action to invoke the method in main window, or communicate with the ViewModel of the main page when you want to receive commands from the changing values on the first window and displays them, see Data binding and MVVM - .NET MAUI | Microsoft Learn
Here's the code snippets below for your reference:
private void OnCounterClicked(object sender, EventArgs e)
      {
Window secondWindow = new Window(new NewPage( FirstImage, "First window String to Second", ( string second) =>
            {
                  CounterBtn.Text = second;
})) ;
var displayInfo = DeviceDisplay.Current.MainDisplayInfo;
secondWindow.X = (displayInfo.Width / displayInfo.Density - Window.Width) / 2;
secondWindow.Y = (displayInfo.Height / displayInfo.Density - Window.Height) / 2;
            Application.Current.OpenWindow(secondWindow);
}
public NewPage(Image firstImage, string firstTitle, Action<string> firstTitleAction)
{
InitializeComponent();
SecontTitleLabel.Text = firstTitle;//get the text from first window
firstTitleAction("SecondTitle");
}

Switch between first sheet(tab) and previous sheet on sublime text

I am trying to program a plugin for myself to switch tab automatically. When I change to other window, the first tab will be shown. When I change back to sublime, the editng tab will show up. I got the following code, which can switch to the first tab. But when I get back to sublime text , it hangs , instead of switching back the tab. Anything I have miss understand with sheets? Thanks!
import sublime
import sublime_plugin
class ShowSheets(sublime_plugin.EventListener):
"""
Display the name of the current project in the status bar.
"""
orisheet = 0
def show_1st(self,view):
if view.window() is None:
return
self.orisheet = view.window().active_sheet()
firstsheet = view.window().sheets()
view.window().focus_sheet(firstsheet[0])
def show_original(self,view):
if view.window() is None:
return
if self.orisheet == 0:
return
view.window().focus_sheet(self.orisheet)
def on_activated(self, view):
self.show_original (view)
def on_deactivated(self, view):
self.show_1st (view)
This is because you have created an infinite callback loop - on_activated and on_deactivated are called when a tab gains or loses the focus.
Thus, when the ST window loses the focus, on_deactivated runs once. Then, when the ST window regains the focus, it calls on_activated once. Then, your code switches the active tab, so on_deactivated and on_activated are executed again, and the cycle repeats indefinitely.
Probably you could work around this by checking which tab is already active, and don't set the focus to the currently active tab. But, you may find that your code will just prevent you from ever being able to switch tab, because there is no real way to tell when a Window loses focus vs. when the active tab has changed.

Unity UI : How to reenable a dropdown after its panel was deactivated and then reactivated?

I am new to Unity, so this is probably a dumb question but here goes:
I have a Unity app; it has several scenes. One of those scenes has a Canvas upon which there are several overlapping Panels. On one of the Panels (PanelA), there is a Dropdown. When the app first runs PanelA is active and on top by default and the dropdown works fine. But after I deactivate PanelA with a C# call to
panelA.SetActive(false);// hides the panel
and then later reactivate it like so:
panelA.SetActive(true); // redisplays the panel
The dropdown no longer displays its list of option when clicked on. The dropdown is still there and still shows its first option "None" and when clicked on the drop-down changes color to indicate that it was touched, but the dropdown does not drop down its list of options.
What am I missing? Why doesn't the dropdown show the list of options?
Thanks
Windows 10 Pro v1709, unity 2017.1.1f1 Personal
My hierarchy is like so, PanelB is the panel that gets set active after PanelA is inactivated:
The script called when the dropdowns option is selected is called like so in Start():
PickDropDown.onValueChanged.AddListener(delegate {
myDropdownValueChangedHandler(PickDropDown);
});
and the called function is:
private void myDropdownValueChangedHandler(Dropdown target) {
Debug.Log("selected: "+target.value);
stage = 0;
currentval = PickDropDown.options [PickDropDown.value].text;
advice.text = "";
title.text = currentval;
if (currentval != NONE) {
advice.text = "You chose to do "+currentval;
nextVal();
}
}
void newVal(){
Debug.Log("newVal " );
PanelA.SetActive (true);
PanelB.SetActive (false);
Debug.Log("options count="+ PickDropDown.options.Count );
}
void nextVal(){
Debug.Log("nextSet " );
PanelB.SetActive (true);
/*** next line shows the answer to my problem - from killer_mech **/
Destroy(PickDropDown.transform.Find("Dropdown List").gameObject);
/***************************************************************/
PanelA.SetActive (false);
}
Yes, this is a bug in unity. I can reproduce this now. This is happening because Unity is creating a game Object called "Dropdown List" inside dropdown which should get destroyed after the closing. But I have noticed a slight delay is happening while destroying(I used editor debug mode for this). When you set the game object active flag as false, it somehow stops the destroy object and results in object Dropdown List staying there so next time when you try to interact with it the object will still present. You will also notice a white box below the Dropdown list after this which indicates the dropdown list still is present.
For the solution what I did was just before I was about to turn my gameobject off I used
Destroy(PickDropDown.transform.Find("Dropdown List").gameObject);
Destroying this object solves the problem. I know this is not a good way to do it, but I checked whether any references to options are destroyed while destroying this which resulted in no error for me. And Dropdown creates new "Dropdown List" gameobject. So it is safe to assume that destroying is OK. Well not sure if any other good solution for this is out there but for now you can use this.
Note: I have tested this bug with Panel, Empty Gameobject as parent and finally with Dropdown
This shows what is happening inside the drop-down. 1) During No popup 2) During Open 3)After setactive off before the child is destroyed.

How to refresh GXT's combo box after each call

I have a combo box. When I click a link, it opens a popup including a combo box (with data loaded from database). It always keeps data from the first call (it does not refresh).
How can I refresh this?
VerticalPanel vp = new VerticalPanel();
vp.setSpacing(10);
ListStore<State> states = new ListStore<State>();
states.add(getStates());
ComboBox<State> combo = new ComboBox<State>();
combo.setEmptyText("Select a state...");
combo.setDisplayField("name");
combo.setWidth(150);
combo.setStore(states);
combo.setTypeAhead(true);
combo.setTriggerAction(TriggerAction.ALL);
vp.add(combo);
Assuming, that you are working with GXT and there fore are using the GXT Window class, you can do something like this:
myWindow.addBeforeShowHandler(new BeforeShowEvent.BeforeShowHandler() {
#Override
public void onBeforeShow(BeforeShowEvent event) {
mxComoBox.clear();
}
});
You see the old value, because a popup will be reused. so you have to clear the value of the combo, when the popup get visible.
This code should work with GXT 3.1.2. Older versions of GXT might have a different coding.
Hope that helps.

Dynamically reload a table in a form programatically

I have a form in Dynamics AX which displays a table of two columns in a grid. I also have a button on the form. I am overriding the clicked method of the button to update the Address field of the table. For example, here's my X++ code:
void clicked()
{
AddressTable addr;
ttsBegin;
select forUpdate addr where addr.addressID == 1;
addr.Address = "new address";
addr.update();
ttsCommit;
super();
// reload table here
}
What I would like to do is to add a code to the clicked function which will reload (re-select) the updated records and show them in the form without a need of reopening the window or refreshing it using F5 (for example).
I went through forums and AX documentation and found a few methods like refresh and reread, but they are FormDataSource class methods and I failed to make it happen inside the clicked handler above.
So, what I really want to accomplish programaticallyis what F5 does behind the scenes when clicked on an open form.
Maybe just addressTable_ds.research(true); will do the job.
See also Refresh Issue on the form when the dialog closes.