enter image [enter image description here]1description here hi when i give details and click on button one popup appears which is having two tabs how to switch between those tabs?
Util.NavigateToLoginPage(ref Driver);
HomeWf.Login(Driver, Username, Password);
var homePage = new PrimaryNavigation(Driver);
homePage.ClickOnMainNavigators(Driver, MainNavigation.Products);
homePage.ClickOnSubMenuOptions(Driver, SubMenuLinks.Products.AddNewProduct);
var bulndlepage = new ProductHomePage(Driver);
bulndlepage.LnkBundleProduct.Click();
//bulndlepage.TxtBrowseNode.SendKeys("Mobile Phones");
bulndlepage.SelectCategory(Driver, "Books"
Console.WriteLine("TxtTitle PRINTED");
bulndlepage.TxtSku.SendKeys("6701");
Console.WriteLine("TxtSku PRINTED");
bulndlepage.ChkCod.Click();
Console.WriteLine("ChkCod PRINTE
bulndlepage.ChkOffline.Click();
Console.WriteLine("ChkOffline PRINTED");
bulndlepage.BtnSaveNext.Click();
bulndlepage.BtnSaveNext.Click();
bulndlepage.BtnAssociateProd.Click();
Driver.SwitchTo().Window(Driver.WindowHandles.Last());
You need to stock your first window name and your popup name.
//Click on your PopUp
driver.FindElement(By.CssSelector("input[id*='IdElemToCLick']")).Click();
string LastWindow = null;
string FirstWindow = null;
foreach (var item in driver.WindowHandles)
{
//Stock first window name
if (FirstWindow == null)
{
FirstWindow = item;
}
LastWindow = item;
}
if (LastWindow != null)
{
// Go to PopUp
driver.SwitchTo().Window(LastWindow);
// Do something with this PopUp
[...]
// Go back to Main Page
driver.SwitchTo().Window(FirstWindow);
}
I see the window appears is a Modal window. You can simply get the id/cssSelector/xpath of the tabs and click on them as required.
Related
I am using codename one swipe tabs dynamically to prepare some radio button but on swiping of tabs getSelectedIndex () method is giving the previous tabs value(previous in the sense suppose I move my tabs from 0 to 1 so it's giving me 0) so how to get the current tab value at which my tab is because on basis of this selectedIndexTab value I want my radio button to get selected.
Here is my code
TableLayout t1=new TableLayout(1, 5);
radioTypeContainer=new Container(t1);
for(i=0;i<5;i++){
t.addTab("Tab2"+i, new SpanLabel("Some text directly in the tab"));
firstTab = new RadioButton[i];
plain = new RadioButton("");
plain.setName("rdb"+i);
rbt =new RadioButton();
rbt.setName("rbt"+i);
radioTypeContainer.add(rbt);
finalRadioList.add(rbt.getName());
finalRadioList.add(t.getTabUIID());
}
borderLayoutContainer.add(BorderLayout.SOUTH,radioTypeContainer);
t.addSelectionListener((i1, i) -> {
Log.p("====***======="+t.getSelectedIndex());
});
Thanks in Advance
newSelected in selectionchanged method gives the current position of tab as shown in below code.
t.addSelectionListener(new SelectionListener() {
#Override
public void selectionChanged(int oldSelected, int newSelected) {
Log.p("====***======="+newSelected);
}
});
I have opened the link now i am clicking on login link on that page,
By clicking on login button its opening in a new tab automatically. I have to fill the form in that tab. For that i tried following code:
Actions act = new Actions(Initialsetupfirefox.driver);
new Actions(Initialsetupfirefox.driver) .keyDown(Keys.CONTROL).click(Initialsetupfirefox.driver.findElement(By.xpath("//a[contains(text(),'LOGIN')]")))
.keyUp(Keys.CONTROL)
.perform();
Thread.sleep(3000);
new Actions(Initialsetupfirefox.driver).sendKeys(Initialsetupfirefox.driver.findElement(By.tagName("html")), Keys.CONTROL).sendKeys(Initialsetupfirefox.driver.findElement(By.tagName("html")),Keys.NUMPAD2).build().perform();
By this i am able to switch the focus but not able to do anything in this tab.
Please suggest
you can do like this:
Set<String> handles = driver.getWindowHandles();
String currentHandle = driver.getWindowHandle();
for (String handle : handles) {
if (!handle .equals(currentHandle))
{
driver.switchTo().window(handle);
}
}
//fill your form in the other tab
......
//go back to first tab if you want
driver.switchTo().window(currentHandle);
This it the code when using selenium with Node.js and Typescript
const mainHandle = await this.driver.getWindowHandle();
// load new tab here ..
const allHandles = await this.driver.getAllWindowHandles();
for (const handle of allHandles) {
if (handle !== mainHandle) {
await this.driver.switchTo().window(handle);
}
}
Get the browser-tabs and do as you like:
List<String> browserTabs = Lists.newArrayList(driver.getWindowHandles());
driver.switchTo().window(browserTabs.get(1)); // Switch to second tab
// Do something on second tab here...
driver.switchTo().window(browserTabs.get(0)); // Return to first tab
// Do something on first tab here...
I have a Ribbon Form with a treelist on the left so i put a XtraUserControl to insert a DocumentManager in which i would like to add all my tabbed forms (like in Visual Studio).
How can i do this?
Thanks
I suggedt you start from the How to: Display Documents Using a Tabbed UI example. The main idea of this example is that you can add the DocumentManager onto the form and then handle a treelist item's Click to add all needed child forms as MDI-children - the DocumentManager will track all the changes automatically:
Form childForm = new Form();
childForm.MdiParent = this;
childForm.Show();
To read more about the another Document Manager concepts and features please refer to the corresponding documentation articles.
public void Viewchild(Form _form)
{
//Check Before Open
if (!IsFormActive(_form))
{
_form.MdiParent = this;
_form.Show();
}
}
//Check If a Form Is Opened Already
private bool IsFormActive(Form form)
{
bool IsOpened = false;
//If There Is More Than One Form Opened
if (MdiChildren.Count() > 0)
{
foreach (var item in MdiChildren)
{
if (form.Name == item.Name)
{
// Active This Form
xtraTabbedMdiManager1.Pages[item].MdiChild.Activate();
IsOpened = true;
}
}
}
return IsOpened;
}
open form in
Master.frmBranch fb = new Master.frmBranch();
fb.Name = "frmBranch";
I want to insert a hyperlink with displayText into a richtextbox at the current caret position, I am displaying a popup window for the user to enter the linkURL and the linkText when the user clicks on the Ok button the hyperlink with the display text should be inserted at the current caret position in the RichTextBox.
Thanks in advance.
Test This Code
Hyperlink link = new Hyperlink();
link.IsEnabled = true;
link.Inlines.Add(" Microsoft ");
link.NavigateUri = new Uri("http://www.microsoft.com");
var allRang = new TextRange(Rich.Document.ContentStart,Rich.Document.ContentEnd);
if (allRang.Start.Parent is Run)
{
var run = allRang.Start.Parent as Run;
var runBefore =
new Run(new TextRange(run.ContentStart, Rich.CaretPosition).Text);
var runAfter =
new Run(new TextRange(Rich.CaretPosition, run.ContentEnd).Text);
if (allRang.Start.Paragraph != null)
{
allRang.Start.Paragraph.Inlines.Add(runBefore);
allRang.Start.Paragraph.Inlines.Add(link);
allRang.Start.Paragraph.Inlines.Add(runAfter);
allRang.Start.Paragraph.Inlines.Remove(run);
}
}
I'm working on a desktop application. It has a dropdown menu. When a menu item is clicked on the dropdown a new tab is opened if it's not opened before. There is a single tab for a single dropdown menu item. What i want to do is to open a window, page or user control(i'm not sure which i should use) in seperate tabs considering the work they will do.
My partial XAML:
<dxd:DockLayoutManager DockItemClosing="DockLayoutManager_DockItemClosing_1">
<dxd:LayoutGroup>
<dxd:TabbedGroup Name="tabbedGroup">
</dxd:TabbedGroup>
</dxd:LayoutGroup>
</dxd:DockLayoutManager>
and partial CS:
private void addPanel(string caption)
{
var contains = false;
var layoutPanel = new LayoutPanel() { Caption = caption };
BaseLayoutItem[] baseLayoutItem = tabbedGroup.GetItems();
foreach (var layoutItem in baseLayoutItem)
{
if (layoutItem.Caption.Equals(layoutPanel.Caption))
{
contains = true;
}
}
if (!contains)
{
tabbedGroup.Add(layoutPanel);
}
}
As i mentioned i want to append a window, page or user control(i'm not sure which i should use) into every LayouPanel opened seperately.
Ok it's as easy as:
layoutPanel.Content = new UserControl1();
And i got one more trick for dynamically creating the desired tab:
layoutPanel.Content = Activator.CreateInstance(Type.GetType(Constants.s_tabs[caption]));
I hope it won't cause any performance problems.