Cant find the right xpath on a website - eclipse

I am using selenium webdirver to log into a website and click a couple of buttons. The website that I want to connect to is twitch.tv. I can get it to click the log in button on top but cannot send keys to the username or password. It gives me an error when I try to use the username xpath of
//*[#id="loginForm"]/div[1]/input
and the password xpath
//*[#id="loginForm"]/div[2]/input
Whenever I try these xpaths I get a no such element exception.
If someone could help me get the right xpaths for these elements that would be great.

The login form and it's inputs are inside an iframe. Switch to it first.
Java:
driver.switchTo().frame("passport-login");
Python:
driver.switch_to.frame("passport-login")

Related

use htmlunit how to get modal dialog element

I want to go to the website https://console.mobra.in by htmlunit tool, but login input in the modal box, how to get username input element or login form?
Use the queryselector method in HTMLUNIT.
usernamebox = currentPage.querySelector("[placeholder='username or email address']");
passwordbox = currentPage.querySelector("[data-ng-model='user.password']");
To get the above CSS selector, you may install chrome extension 'CSS Selector' of using the selectorgadget.
If it works, please tick it as answer, or otherwise please leave a comment below.

How to get element id in google forms

I want to get the id of an element in google forms. I found on the internet that it can be done by right clicking on the element and opening inspect element. It is working for older forms but, for new forms, it doesn't show any id attribute. I am posting both images of inspect element.
Old forms:
New forms:
In new form google have replace id with name attribute.So do one thing, write something in textbox then rightclick on textbox and open inspect element, Here you will find item tag with name attribute which is the key you want
For eg,
<input name="entry.123456" >
Maybe I can help you in finding the id's of the element.
After submitting the form you can look for headers{Form Data} in the network section of developer tools.
You will find something like this..
entry.102708304: "Your response"
102708304 is the id..
Hope my answer was useful. Thank You.
Try pressing Ctrl+U when on the Google Website. In Firefox this will show up the complete HTML Code where you can search better. There has to be set an Id, because otherwise the text in the element couldn't be accessed
hi this has changed a bit,
you need to get a pre filled link via 3 dot menu then prefilled link , copy it into an editor and confirm these entries.
I could not find it visible anywhere in the source code and there are a ton of JS names that seem random and 0 name inputs on my form

Facebook LIKE fires error

I am creating application on localhost (XAMPP). When I try to test LIKE button this error pop ups:
**Message Failed: This message contains content that has been blocked by our security systems.**
Either the URL you wanted to like is blocked by Facebook or you are trying to like a Link on localhost - which is not possible, of course. You can only like public URLs.
Put the URL in the Facebook Debugger to check if it´s available: https://developers.facebook.com/tools/debug/
You can also just try to post it on your own Facebook Wall to test if it is blocked.
go to the link given below: https://developers.facebook.com/docs/plugins/like-button
Type your link in URL to Like. for example: https://www.facebook.com/games/rajvirbalapp/
Type width in next input box.
Select your Like button Layout from drop down. For Example: box_count.
Select Action Type from Drop down. For example: Like.
Tick Show Friends' Faces or Include Share Button if you want to show share button.
Click Get Code button and copy the script and paste where you want to show the like button in your website.
If you use localhost then it will display error message other wise it work's.
Best of luck.

how to send facebook message automatically without api

guys
now i knew how to send message without using facebook api,
i could use url to fill the message textarea in facebook's website
www.facebook.com/messages/[user_id]?msg_prefill=XXX
but here i'd like to know how to send this message automatically
in April, i found a way to click "send" button automatically (find "send" button in html text and click it),
but now facebook hide theses html text so that i can't find this button in html text.
Therefore, can anybody provide some ways or point to send message automatically.
thanks
Use the console in you browser (usually F12 to open) firefox console is the most powerfull, your console should have a command like "element inspection" or similar, use this tool to analize the button you want, read ing the code you should find someting like "on click" or simsimilar, after this you will find a java command to push the button. Anyway to do this kind of stuff without being a programmer,use selenium IDE, very easy,only for firefox,you must download it from firefox as add on. Good luck!

Grab html code by entering username and password on a webpage on iPhone

Im trying to grab a HTML source code from a webpage which needs user to login with username and password, the code are all done in the back end, i can not use "?username=xx&pw=xxx" to get the html code.
There are many apps that does this kind of things, such as getting usage from a phone provider or view bills.
I would like to know how do people implement this. do they create some kind of robot that input those username into the textfield and click submit? and is there a way to download the html straight from the server, rather than create our own server to retrieve it.
How do i set the username textfield on the webpage and click log in button to retrieve the next page?
Thanks in advance
i can not use "?username=xx&pw=xxx" to get the html code.
Why not? If a user can submit their login creds over HTTP, then you can do the same. You'll probably need to use POST instead of GET to submit those fields, and there may be other fields on the form that you'll need to match. But the web server doesn't (in principle) have any idea what sort of client is submitting login data to it.
Now, they might screen out older, non-supported browsers, in which case your USER_AGENT field will need to be fudged to some legal value. There may be some session timeout token in the form that you need to get first and provide in your submitted data. Who knows what else they need back from you to validate the login. But if a web browser can do it, you can do it from the HTTP client methods in your app.