so im currently trying to copy a message to automate a login sequence. The login requires an otp code that has to be sent to a phone. I set up a textnow account to gain access to the otp via web page but the problem comes in when trying to find the latest message. How could I specify that I want the latest element copied even though the html for each individual message looks exactly the same. The only thing that differentiates them is the otp given and time.
How could I identify the latest message to the bot and copy it ?
senderofotp = driver.find_element_by_xpath('//*[#id="chat-preview-list"] /ul/li[1]/div[2]/div[1]/span/div')
senderofotp.click()
The code above is how I selected the sender of the message.
message = driver.find_element_by_xpath('//*[#id="messageView"]/ul/li[30]/div/div[1]/div/div[1]/div/span/span')
even when I try to grab the message it gives me the xpath to the message view as a whole
you may use find_elements_by_xpath to find list of elements at once
Related
I am using selenium python to send a message to a user.I made my code and it was working for an account but when I tried with a different account the interface was totally different
For example -
in my first account
you can see the message icon is in the left side and I made my program according to that xpath,but now I signed up with a different account and the interface and xpath was totally different like -
How would I handle this type of bug in selenium python or How can I identify which account has which interface?
thankyou for your time
I tried to message a username through selenium and I expected the xpath for every account will be same but it was not
I'm new here and I'm trying out my first automated scripts using robot framework.
I'm trying to create a keyword test that will create and send out a notification to some users, but at the end of the process, I need to find that created notification by ID, so I can assure that its status is now equals "Sent".
Right now my keyword test is working, but it's just creating the notification and validating the success message at the end, but I would like to include one more validation as mentioned before, find the notification by the generated ID and check if the status column for that ID is equal to "Sent".
I've managed to store the generated ID into a variable during the notification creation process, but now I need to find that ID on a page with a table containing a bunch of other IDs and their statuses.
For now, I just added the following at the end to try to get that:
Wait until page contains element ${sentstatus)
the xpath for that is:
//a[contains(#href,'/cms/Notifications/Edit/') and text() = 'Sent']
The problem with this xpath is that it will find a bunch of results, since I'm not passing the generated ID, otherwise it would work, for example:
//a[contains(#href,'/cms/Notifications/Edit/123456') and text() = 'Sent']
It would be great if I could add my variable containing the generated ID into that xpath, but that seems like something that is not supported, for example:
//a[contains(#href,'/cms/Notifications/Edit/${notificationID}') and text() = 'Sent']
Sorry if that might be a simple question for some of you guys, but I'm really stuck here, please help me lol
Thanks in advance!
You can try :
Wait until page contains element //a[contains(#href,'/cms/Notifications/Edit/${notificationID}') and text() = 'Sent'] 15s
I think robot framework don't work with
Wait until page contains element ${sentstatus) 15s
I'm trying to scrape my Instagram DMs (direct messages). However, I don't know how to automate scrolling down the column to get the additional usernames that messaged me.
I've tried this, as well as the scrolling code listed here.
However, neither work because Instagram's DM page is broken into columns. The full page itself does not need to be scrolled. Just the first column. For reference, here's a screenshot of what the Instagram DM page looks like. I blocked out my username and the usernames of people who DMed me for privacy reasons
Does anyone have any ideas on how I can modify the script that scrolls down the page to accommodate the column size?
Thank you for taking the time to read my question and help in any way you can.
You should instead try to use the export data feature on Instagram, you will get the JSON files of all the messages and media you have sent or received. This will make your task a lot easier.
https://help.instagram.com/contact/505535973176353
https://www.instagram.com/download/request/
Instead of targeting the window you should target the messages box element to scroll:
scroll_y = 1000
driver.execute_script(f"document.getElementsByClassName('N9abW')[0].scrollTo(0,{scroll_y})")
if it doesn't work with class name try with Xpath:
path = "//*[#id='react-root']/section/div/div[2]/div/div/div[1]/div[2]/div/div/div"
script = f"document.evaluate({path}, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.scrollTo(0,{scroll_y});"
driver.execute_script(script)
Adjust scroll if needed
I am trying to log my user with a link generated from me, basically this is the workflow, a user wants to fill a form from my site, but they comunicate through whatsapp, so i will generate a link for them, but the catch is they have to log in once they go into the page, since they will fill some sensitive data , plus, id like them to get logged into the system and use other functionalities if they want.
Security wise, i will always know if the user is who they say when they message me bc i can recognize the phone number, so i dont need them to log in again once they click the link and go into the browser. Dont get me wrong i want the user to be able to log in if they want from their computer, but it makes it a lo easier if they dont have to do that form mobile.
Based on the phone number i will know the user, so what i need is generate a link where they will click and it will be self authenticating, meaning they will be logged with this link and forwarded to where they neeed.
I'd appreciate any recomendations or tecnologies to do this implementation
You will have to send links with generated api-tokens that allow them to log in for a certain amount of time after you generate the link.
The link may be something like https://yoursite.com/api?token=the_special_token and then in your login View, you write a function to check the validity of the token against the user's phone number provided.
You can use on django's token module to generate and authenticate the tokens.
I tried using newly released Inbox api to sort out and tag my mails, but I am stuck at categorising mails after I had successfully logged in using api.
I am not quite sure where exactly you are struck , but please refer to the following document https://www.inboxsdk.com/docs/#ComposeView though it is documented in javascript