Selenium Address Bar - selenium

Good morning
I am using selenium and I have come up against a bit of a wall.
I am attempting to navigate to another page, by typing in the address bar, however I cant seem to do this when using selenium.
Is this possible?
I am not able to simply put a link on the page that goes to this page.
Cheers Cameron

Short answer: Try the "open" command.
Long answer: Selenium doesn't support "typing in the address bar". It can only control what is IN the page canvas, or more specifically, it can only do what JavaScript can do. In other words, it can change the location, but not by actually typing something in to the address bar. The open command uses JavaScript to change the page's location.

The address bar is where you put the base url,
and to use the open the url you need to use the selenium open command,
EX:
Base URL: google.com
command1#
command = open
target = /

Related

When writing end to end selenium tests, should I navigate to a page or just open the URL?

Say I need to submit a form on the 'Classes' page. I am testing the 'enroll into class' feature. Do I navigate to the page by clicking on the menu bar, or do I just directly open the URL of the page?
It depends on the scenario you need to test.
As an autoimation engineer you need to work according to the documentation.
If no scenario defined you can choose easiest way to do that.
Incase clicking on the menu bar is the part of your #Test, you have to access the base page and navigate to the desired page by invoking click() on the menu bar.
Else you can directly open the URL of the page.

Selenium Chromedriver call to logout page not working

I want to write an automated test with Selenium using Chromedriver and Behat.
This scenario in question should go to a page, register a user, logout and register another user.
Now the problem is, on the website in question, after registration you get an annoying overlay, so that the logout button is not reachable anymore. I can either make the test fill out the overlay and complete it properly, which will take much more effort, or try to logout some other way.
My idea was to simply go to the domain again with /?event=logout added which normally works to log out the current user. However when I do this in the automation it fails, apparently because of a bad http response code.
Is it not possible to use a url like this with Selenium? Anyone have an idea?
You can achieve this with Selenium using a site that makes GET requests. So you can go to URL http://requestmaker.com/, fill the www.website.com in the Request URL, and 'event=logout' in the Request data, then click "Submit".
It's a bit hacky, so I would prefer using a GET request directly in the code, depending on your programming language... Something like so:
https://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/
Some options would be:
Navigate to URL to logout and try to hide the modal via jQuery/javascript
After registration navigate to homepage and see if the modal is there and if you can logout as you should
Clear session and navigate to the page you need
Pick one of them.

Client-side Javascript: Showing the browser's address bar when a site hides it?

I'm trying to make a short client-side script that will run as UserJS in something like Greasemonkey. The script is to prevent sites from hiding the browser's navigation buttons. Topic info here.
I've come up with Window(location=yes, toolbar=yes, menubar=yes); This gives a "Read-Only" error though. All the info when I search is about web authors wanting to turn off the address bar (etc), not users wanting to turn it back on.
Click a product on this page to see the problem.

Selenium enter text to field without an identifier

I wonder if anyone know hoe to enter text into a field without any identifier. What happens is that i go to a website and are displayed a log on page in front of the web browser. If i now use F12 will I receive all the info about the page in the background except for the log in page.
Is there a way to blindly enter text, press tab, enter some more and then press enter?
I will make wild guess: That log in page uses HTTP basic authentification and you need to get to that page using Selenium.
If so, simply use this:
driver.get("http://username:password#your-test-site.com");
Where driver is healthy instance of WebDriver
EDIT
In my testing, I had the same issues as you are having. So try this:
Go to your test site manually
Manually log in
Grab the URL you have been redirected to. In my case its something like http://my-test-site.com/faces/pages/admin/admin.xhtml
Use that url to get to the site - i.e: driver.get("http://username:password#my-test-site.com/faces/pages/admin/admin.xhtml");
Assuming you are using firefox, you can take a couple of approaches:
Create and use a profile where you have the username and password saved.
Try whitelisting your domain on Firefox preferences like this:
profile.SetPreference("network.automa
tic-ntlm-auth.trusted-uris", "domain.com");
driver = new FirefoxDriver(profile);
driver.Navigate().GoToUrl("http://user:password#domain.com");

Bring Safari to front

I'd like to bring Safari to the front (switch to) but without using a URL, instead I'd like to see the "pages" view so the user can pick an already loaded page. Is this possible?
We open links in Safari and if the user returns to the app and selects the link again, I'd rather let them pick which Safari page to browse instead of opening a new one. I know that if the same URL is called it will open the correct page but the user may have navigated within the original site so the url no longer matches.
Thanks,
Rick
I don't think that its possible, i would use a UIWebView inside your app in order to get that experience you want, you can find the UIWebView apple docs here (http://developer.apple.com/library/ios/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html) and also the equivalence of c# methods here (http://tirania.org/tmp/rosetta.html) hope this helps
Alex
Your app doesn’t get control of Safari’s UI. You might, however, be able to design your site so that it handles navigation via Javascript—AJAX and whatnot—so that the actual page URL doesn't change, and thus so that the page, re-opened from your app, brings up the existing Safari page. Of course that introduces further problems with your pages no longer being bookmarkable, but you might find that an acceptable tradeoff.