I have an mvc app to test and my code works with Chrome but not Phantom. It can't find a simple input control with id = "password" on the logon page. I've tried different selectors, xpath, by class, by ID, even different controls on the page. It can find the "body" tag and the very next, but nothing is working to find anything past the next level in
I've also tried driver.waitforpageload and thread.sleep to make sure things are loaded first, no avail. Ideas anyone?
It can't find a simple input control with id = "password" on the logon
page.
and
It can find the "body" tag and the very next inside tag
"app-controller", but nothing is working to find anything past the
next level in, the view-manager tag.
and
I've even tested google.com to see if it was even loading and it can
find controls on that page successfully.
Considering the above, I'm guessing that the Login page is your page in your site after navigating to the URL.
I have encountered the same issue which normally led me think that PhantomJS cannot identify the elements on page. This until I started debugging stuff.
Because of the way how PhantomJS works loading everything headless, more or less in his own 'container' it turned out that it wasn't even able to load my test site, because it didn't had all the necessary prerequisites executed.
To be able to debug, and check if you face the same issue, just print to a log file the content of your page.
You can achieve this by using: var pageSource = driver.Pagesource;
It's highly likely that the last node present will be the body one.
If that's the case, you need to see what prerequisites are required for your site to start working: authentication, HTTPS certificates, etc.
Related
I'm writing Selenium tests in C# with Specflow and Nunit for a new project i'm working on and nothing inside the body can be selected anywhere at all
I can access body with
WaitUntil(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.CssSelector("body")));
but can not of the following work and throe element not found exceptions:
WaitUntil(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.CssSelector("halo-root")));
WaitUntil(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.CssSelector("halo-entry")));`
WaitUntil(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.CssSelector("halo-navigation-container")));
etc
error: no such element: Unable to locate element: {"method":"css selector","selector":"halo-root"}
There are no iframes
I have tried long waits to ensure its nothing asynchronous
the website is angular.js (I have tried some protractor approaches but nothing successfully)
I've also played around wit ElementIsVisible, ElementIsClickable etc
Ive tried different selectors (id, className, xpath etc)
All help appreciated
p.s cant share the entire SUT as it required vpn access.
First check your html. i think body tag must be present in iframe.
If it is present in iframe first switch to iframe then try any commands(wait or actions) on element.
The issue was when logging in through a portal (Jumpcloud) a new tab was opened (that I didn't notice) so the solution was just switch to that new window with _driver.SwitchTo().Window(_driver.WindowHandles[1])
Thanks for all the help though! :)
Helo!
My goal is to retreive data from HPE Service Manager (HPSM). I use webBrowser component as it's seems the easyest way to me. At least I had no problem with authorization and opening search page but the things turned strange as I proceeded.
I need to find element with id "X13" on the page but
wb.document.getElementById("X13");
returns null although executing getElementById in IE and Chrome dev consoles still does the trick.
How can I find the element I need using C# and webBrowser component?
I'm aware that I can navigate backwards through my history using the IWebDriver.Navigate().Back() method, but what if I just need the URL of the last page visited? Is there a way to grab that from the WebDriver, without actually navigating there?
To be clear, this is a question about Selenium WebDriver, and has nothing to do with JavaScript.
As suggested by several, what I ended up doing is wrapping the Selenium WebDriver in my own class that monitors all navigation, and keeps its own history. It seems a redundancy, given that somewhere deep in the bowels of WebDriver another history already exists, but since the tester doesn't have access to it, I see no other way of achieving this goal.
Thanks to all who contributed their thoughts and suggestions!
You can just keep the previous page URL in a variable and update/pass it to the actual code that needs it. Even keep a collection of all visited URLs and just get the last item, all this will give you a history without any need for JS hacks. Storing and sharing state is a valid case, already implemented in some frameworks, like SpecFlow's ScenarioContext. And the previous page URL value will be available to all your steps/code for each test.
I am using Selenium webdriver to automate a web application, that has many frames.
The elements inside frame are not getting identified when I run my scripts in IE,and I get an exception "Unable to find element with link text == testing". But this works perfectly in Chrome and Firefox.
I went through many related discussion, and tried the following work arounds, but they dint help.
Inserted wait statement before and after switching the frame.
Disabled proxy setting for IE.
Modified IE setting to display both secure and non secure contents
Checked 'Allow active contents to run in files on my computer' check box under Internet options -> Advanced -> security in IE settings.
I use,
Selenium webdriver version 2.35.0.0
IE version: 7
Programming language: c#
Note:
The application has dynamic name and id for frames, hence I have used index for switching the frames.
I tried saving the application opened in chrome and IE as a html page. When I open the saved html page using a browser,
The one saved from chrome shows all the elements inside the frame.
The one saved from IE doesn't show any elements inside the frame.
It would be great if I get a solution to handle elements inside the frames.
Am not able to provide the full html code, but have attached the screenshot of a part of html code.
I tried saving the complete html page using Chrome and IE. And I do observe a difference in them.
This is the snapshot of html code that is saved from chrome. Here I do see "< div class="mocha" division, that has the frame.
This is the snapshot of html code that is saved from IE. Here I do not see "< div class="mocha" division, and also "< iframe > ".
I doubt, if this might be the cause for the problem. Let me know, if I had to provide more information.
The actual problem was that, for some reason identifying the frames using Index was not working properly in IE. This seems to be an issue related to application’s behavior with the IE browser. Hence we came up with the following solution to overcome this issue.
Steps:
1. Fetch all the frames in the page (using its class) as a list.
2. Iterate through the list to fetch the name of each frame in an array.
3. Then switch to the corresponding frame using frame name saved in the array.
i am facing one issue in my asp.net 3.5 application.
www.abc.com/default.aspx - this works perfectly
when user tries to add anything after aspx after / like www.abc.com/default.aspx/xyz
my css gets disabled, and page works which i dont want.
i have used error pages but it didnt work in this . i want to disable anything user enters after url www.abc.com/default.aspx
if user enters www.abc.com/default.aspx/xyz it should display error page
how to do it ?
thankx in advance
This belongs to StackOverflow.
but this sounds like is a simple issue that your CSS is relative (does not start with /), try change the <link> in the <head>-section to have a forward slash at first.