1

I'm working in a simple html page that contains a button that open a new tab without "!doctype", and I need to analyze it and go back to the first page

Apparently it is an html page that contains an xml, but I need another solution in Selenium.

I tried this, but I got timeout in

webDriverInstance.switchTo().window(windowTab);

public void switchTab(String url) {

        try {
            for (String windowTab : webDriverInstance.getWindowHandles()) {
                webDriverInstance.switchTo().window(windowTab);

                if (webDriverInstance.getCurrentUrl().contains(url))
                    break;
            }
        } catch (Exception e) {
            log.debug("Não foi possivel trocar aba", e);
        }
        setWait();
    }

View Page enter image description here Source page view-source I thought I would find the answer on this question but it was not exactly my scenario

How to read xml embedded in the page? I want to get compare the value of exportid present in xml structure?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Lucas Neves
  • 113
  • 1
  • 8
  • [Don't do this](https://meta.stackoverflow.com/questions/361474/should-we-display-a-warning-when-users-include-images/361481#361481). Please read why a [screenshot of HTML or code or error is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Consider updating the Question with formatted text based relevant HTML, code trials and error stack trace. – undetected Selenium Aug 24 '18 at 12:53

1 Answers1

0

if you need to switch to new tab try use indexes, if you know for a fact that the tab that you open is last. You can use last flag that would switch to most recently open tab, in C# this does the trick there is also a first flag that will take you to the first tab.

IWebDriver driver = new ChromeDriver();
driver.SwitchTo().Window(driver.WindowHandles.Last());

After that you would need to save the page source and parse the xml

Tomasz Wida
  • 329
  • 1
  • 6
  • 24