cant input in instragam DM using selenium

i tried to make a instagram bot but i wasnt able to send messages does anyone know how i can do that using selenium
5 Replies
Anonymous DEV
Anonymous DEV2y ago
import { By, until, Key } from "selenium-webdriver";
const dmUsers = async (driver, id) => {
console.log(" DMING USERS");
await driver.get("https://www.instagram.com/direct/inbox/");
await driver
.wait(
until.elementLocated(
By.xpath(
"/html/body/div[2]/div/div/div[3]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div/div[3]/button[2]"
)
),
5000
)
.click();
await new Promise((resolve) => {
setTimeout(resolve, 5000);
});
let element = await driver.wait(
until.elementLocated(
By.xpath(
`/html/body/div[2]/div/div/div[2]/div/div/div/div[1]/div[1]/div[2]/section/div/div/div/div[1]/div[1]/div/div[1]/div[2]/div`
)
),
5000
);
await element.click();

await new Promise((resolve) => {
setTimeout(resolve, 5000);
});
const secondElement = await driver.wait(
until.elementLocated(
By.xpath(
`/html/body/div[2]/div/div/div[3]/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div[2]/div[2]/input`
)
),
5000
);
await secondElement.sendKeys(id);
await new Promise((resolve) => {
setTimeout(resolve, 5000);
});

try {
let first_DM = await driver.wait(
until.elementLocated(
By.xpath(
`/html/body/div[2]/div/div/div[3]/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div[3]/div/div/div[1]/div/div/div[2]/div/div/span[1]/span/div/span`
)
),
5000
);
let gettingText = await first_DM.getText();
if (gettingText == id) {
console.log("Account Found");
first_DM.click();
await new Promise((resolve) => {
setTimeout(resolve, 5000);
});
await driver
.wait(
until.elementLocated(
By.xpath(`/html/body/div[2]/div/div/div[3]/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div[4]/div
`)
),
5000
)
.click();
await new Promise((resolve) => {
setTimeout(resolve, 5000);
});
await driver.wait(until.elementLocated(By.xpath("/html/body/div[2]/div/div/div[2]/div/div/div/div[1]/div[1]/div[2]/section/div/div/div/div[1]/div[2]/div/div/div/div/div/div[2]/div/div/div[2]/div/div/div[2]/div/div[1]/p")),5000).sendKeys("hello",Key.RETURN)
}
} catch (error) {
console.log(error, " ID NOT FOUND");
dmUsers();
}
};

export default dmUsers;
import { By, until, Key } from "selenium-webdriver";
const dmUsers = async (driver, id) => {
console.log(" DMING USERS");
await driver.get("https://www.instagram.com/direct/inbox/");
await driver
.wait(
until.elementLocated(
By.xpath(
"/html/body/div[2]/div/div/div[3]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div/div[3]/button[2]"
)
),
5000
)
.click();
await new Promise((resolve) => {
setTimeout(resolve, 5000);
});
let element = await driver.wait(
until.elementLocated(
By.xpath(
`/html/body/div[2]/div/div/div[2]/div/div/div/div[1]/div[1]/div[2]/section/div/div/div/div[1]/div[1]/div/div[1]/div[2]/div`
)
),
5000
);
await element.click();

await new Promise((resolve) => {
setTimeout(resolve, 5000);
});
const secondElement = await driver.wait(
until.elementLocated(
By.xpath(
`/html/body/div[2]/div/div/div[3]/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div[2]/div[2]/input`
)
),
5000
);
await secondElement.sendKeys(id);
await new Promise((resolve) => {
setTimeout(resolve, 5000);
});

try {
let first_DM = await driver.wait(
until.elementLocated(
By.xpath(
`/html/body/div[2]/div/div/div[3]/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div[3]/div/div/div[1]/div/div/div[2]/div/div/span[1]/span/div/span`
)
),
5000
);
let gettingText = await first_DM.getText();
if (gettingText == id) {
console.log("Account Found");
first_DM.click();
await new Promise((resolve) => {
setTimeout(resolve, 5000);
});
await driver
.wait(
until.elementLocated(
By.xpath(`/html/body/div[2]/div/div/div[3]/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div[4]/div
`)
),
5000
)
.click();
await new Promise((resolve) => {
setTimeout(resolve, 5000);
});
await driver.wait(until.elementLocated(By.xpath("/html/body/div[2]/div/div/div[2]/div/div/div/div[1]/div[1]/div[2]/section/div/div/div/div[1]/div[2]/div/div/div/div/div/div[2]/div/div/div[2]/div/div/div[2]/div/div[1]/p")),5000).sendKeys("hello",Key.RETURN)
}
} catch (error) {
console.log(error, " ID NOT FOUND");
dmUsers();
}
};

export default dmUsers;
error
PS C:\Users\Anonymous\Desktop\instagram Advertisement Bot> node .\index.js
Logging into Instagram.
Loged in sucessfully.
DMING USERS
Account Found
ElementNotInteractableError: Element <p class="xat24cr xdj266r"> is not reachable by keyboard
at Object.throwDecodedError (C:\Users\Anonymous\Desktop\instagram Advertisement Bot\node_modules\selenium-webdriver\lib\error.js:524:15)
at parseHttpResponse (C:\Users\Anonymous\Desktop\instagram Advertisement Bot\node_modules\selenium-webdriver\lib\http.js:601:13)
at Executor.execute (C:\Users\Anonymous\Desktop\instagram Advertisement Bot\node_modules\selenium-webdriver\lib\http.js:529:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async thenableWebDriverProxy.execute (C:\Users\Anonymous\Desktop\instagram Advertisement Bot\node_modules\selenium-webdriver\lib\webdriver.js:745:17)
at async Module.dmUsers (file:///C:/Users/Anonymous/Desktop/instagram%20Advertisement%20Bot/modules/DmUsers.mjs:74:7)
at async Run (C:\Users\Anonymous\Desktop\instagram Advertisement Bot\index.js:31:5) {
remoteStacktrace: 'RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8\n' +
'WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:183:5\n' +
'ElementNotInteractableError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:293:5\n' +
'webdriverSendKeysToElement@chrome://remote/content/marionette/interaction.sys.mjs:624:13\n' +
'interaction.sendKeysToElement@chrome://remote/content/marionette/interaction.sys.mjs:598:11\n' +
'sendKeysToElement@chrome://remote/content/marionette/actors/MarionetteCommandsChild.sys.mjs:546:29\n' +
'receiveMessage@chrome://remote/content/marionette/actors/MarionetteCommandsChild.sys.mjs:163:31\n'
} ID NOT FOUND
DMING USERS
file:///C:/Users/Anonymous/Desktop/instagram%20Advertisement%20Bot/modules/DmUsers.mjs:5
await driver.get("https://www.instagram.com/direct/inbox/");
^

TypeError: Cannot read properties of undefined (reading 'get')
at dmUsers (file:///C:/Users/Anonymous/Desktop/instagram%20Advertisement%20Bot/modules/DmUsers.mjs:5:16)
at Module.dmUsers (file:///C:/Users/Anonymous/Desktop/instagram%20Advertisement%20Bot/modules/DmUsers.mjs:78:5)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Run (C:\Users\Anonymous\Desktop\instagram Advertisement Bot\index.js:31:5)

Node.js v18.15.0
PS C:\Users\Anonymous\Desktop\instagram Advertisement Bot>
PS C:\Users\Anonymous\Desktop\instagram Advertisement Bot> node .\index.js
Logging into Instagram.
Loged in sucessfully.
DMING USERS
Account Found
ElementNotInteractableError: Element <p class="xat24cr xdj266r"> is not reachable by keyboard
at Object.throwDecodedError (C:\Users\Anonymous\Desktop\instagram Advertisement Bot\node_modules\selenium-webdriver\lib\error.js:524:15)
at parseHttpResponse (C:\Users\Anonymous\Desktop\instagram Advertisement Bot\node_modules\selenium-webdriver\lib\http.js:601:13)
at Executor.execute (C:\Users\Anonymous\Desktop\instagram Advertisement Bot\node_modules\selenium-webdriver\lib\http.js:529:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async thenableWebDriverProxy.execute (C:\Users\Anonymous\Desktop\instagram Advertisement Bot\node_modules\selenium-webdriver\lib\webdriver.js:745:17)
at async Module.dmUsers (file:///C:/Users/Anonymous/Desktop/instagram%20Advertisement%20Bot/modules/DmUsers.mjs:74:7)
at async Run (C:\Users\Anonymous\Desktop\instagram Advertisement Bot\index.js:31:5) {
remoteStacktrace: 'RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8\n' +
'WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:183:5\n' +
'ElementNotInteractableError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:293:5\n' +
'webdriverSendKeysToElement@chrome://remote/content/marionette/interaction.sys.mjs:624:13\n' +
'interaction.sendKeysToElement@chrome://remote/content/marionette/interaction.sys.mjs:598:11\n' +
'sendKeysToElement@chrome://remote/content/marionette/actors/MarionetteCommandsChild.sys.mjs:546:29\n' +
'receiveMessage@chrome://remote/content/marionette/actors/MarionetteCommandsChild.sys.mjs:163:31\n'
} ID NOT FOUND
DMING USERS
file:///C:/Users/Anonymous/Desktop/instagram%20Advertisement%20Bot/modules/DmUsers.mjs:5
await driver.get("https://www.instagram.com/direct/inbox/");
^

TypeError: Cannot read properties of undefined (reading 'get')
at dmUsers (file:///C:/Users/Anonymous/Desktop/instagram%20Advertisement%20Bot/modules/DmUsers.mjs:5:16)
at Module.dmUsers (file:///C:/Users/Anonymous/Desktop/instagram%20Advertisement%20Bot/modules/DmUsers.mjs:78:5)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Run (C:\Users\Anonymous\Desktop\instagram Advertisement Bot\index.js:31:5)

Node.js v18.15.0
PS C:\Users\Anonymous\Desktop\instagram Advertisement Bot>
Jochem
Jochem2y ago
instagram Advertisement Bot
Are you trying to send advertisement DM's to people on instagram?
Anonymous DEV
Anonymous DEV2y ago
wana make fully automated bot that would reply to messages follow unfollow everything
Anonymous DEV
Anonymous DEV2y ago
i wana make smth like this using selenium https://github.com/adw0rd/instagrapi
GitHub
GitHub - adw0rd/instagrapi: 🔥 The fastest and powerful Python libra...
🔥 The fastest and powerful Python library for Instagram Private API 2023 - GitHub - adw0rd/instagrapi: 🔥 The fastest and powerful Python library for Instagram Private API 2023
Jochem
Jochem2y ago
I have no experience with either selenium or instagram, so I can't help
Want results from more Discord servers?
Add your server