Selenium enter text to field without an identifier - selenium

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");

Related

Zabbix web scenario authentication

So i'm trying to set up zabbix web scenario to monitor webpage up/down. Ive found a way googeling which should work for me, however there is an issue in the login page. I need to be able to press TAB 4 times and then end it with a space to reach the login information panel. But i can not figure out how to tell zabbix to insert TABs or Spaces on the page before it attempts to login.
by default SMART-ID is our main authentication, and the order can not be changed as it would interfere with our user welfare policies. So i need to make zabbix able to navigate to the "Parool" tab for login. Also using the tab key on the page visualy does nothing untill you press the space bar, only after space bar it actually shows you where you have navigated.
So far i have tried to simply add tab and space in the "post fields" section however this does not do anything and i have not managed to google the information i require.
That's not how Zabbix Scenarios works.
Zabbix uses libCurl to check web endpoints, not a browser: you can't render javascript nor post/click to forms (ie: like Python Splinter does).
You can post data to specific web endpoints, like http://somewhere/test.php?id=2345&userid={BLABLABLA} then grab the output and/or the resulting http return code.
Please refer to the documentation for a complete overview.

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.

Login to Google from iFrame

I have seen that it is not possible to display any Google page from an iframe. An error message is displayed: cannot display, open in a new window.
I need to login to Google (OpenId authentication) from an iFrame in Joomla (cannot change this). Is there a workaround for this? I thought I could open the authentication page in a new window, and then try to kill that window and reload the original one, but I am not sure I can do that.
Thanks
Well you can just get the form (html code) and put it in your iframe but this will get very messy, for example, there maybe certain JS files that you need to include as well.
Redirecting to Google is best way to implement it.As Using IFrame Sometime does not allowed by some Companies Due to Security.

How to detect if user has switched Rails 3

A user logs into my application in a tab in a browser
They get an email and click a link which opens a new tab in the same browser and logs them in under a different email say.
If they go back to the first tab they are no longer the same user and I want the page to automatically detect this and then reload or redirect them if they are unauthorized to view the page.
Anyway to do this?
Or, if you really want to know when user is switched the tab, try this library:
visibility.js
As stated by #Hck:
add javascript code to reload page periodically (for example once per 30 seconds) – Hck
JavaScript is pretty much the only way to make pages do stuff after they're loaded. Note that in pretty much any user authentication system, a given browser will only be logged in as one user at a time, so as soon as the second tab opens, that browser will be acting as the second user - they can still see the current content of the first tab, but links (for instance) will no longer work unless the second user was also authorized to use them.
There are some JQuery plugins that do this sort of thing, like PeriodicalUpdater, or you can write your own (an example).

Selenium Address Bar

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 = /