Selenium Webdriver call function Java Scipt

0 votes

I want to call a function after selenium sees and get the text of a link on page,

driver.get("https://www.guerrillamail.com/");

driver.findElement(By.id('inbox-id')).getText().then(function(gm){

address = gm + "@sharklasers.com";

var output = new Buffer(address, 'hex');

console.log(output);

mailExistsCheck();

var query = driver.wait(until.elementLocated(By.xpath("//*[contains(text(), 'confirm@ksmobile.com ')]")));

query.click();

var query2 = driver.wait(until.elementLocated(By.partialLinkText("iptlogin")));

query2.getText();

var target = query2.getText();

After selenium finds this driver.wait(until.elementLocated(By.partialLinkText("iptlogin"))); I want to start a function called activateMail(target).

i Need to do something simular to this

var link = target.includes("iptlogin");

if (link = true) {

activateMail(target);

console.log("True");

}

Jun 14, 2018 in Selenium by Martin
• 4,320 points
3,786 views

1 answer to this question.

0 votes

To run Javascript with selenium web driver you should  use JavaScriptExecutor method, with the Following syntax :

JavascriptExecutor js = (JavascriptExecutor) driver;

js.executeScript(" var link = target.includes('iptlogin'); if (link == true) { activateMail(target); console.log('True'); } ");

answered Jun 14, 2018 by Samarpit
• 5,910 points

Related Questions In Selenium

+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
7,967 views
+1 vote
1 answer

How to perform mouse hovering in Selenium WebDriver (Java)?

You many not actually be able to ...READ MORE

answered Apr 3, 2018 in Selenium by nsv999
• 5,500 points

edited Aug 22, 2023 by Khan Sarfaraz 10,286 views
0 votes
1 answer

Java.lang.CharSequence cannot be resolved error while using sendKeys() using Selenium Webdriver

You could try this, myElement .sendKeys(new String[] { ...READ MORE

answered Apr 4, 2018 in Selenium by Johnathon
• 9,090 points
4,347 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
12,754 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,623 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
6,697 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,561 views
0 votes
2 answers

Selenium Webdriver Error: org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'

Facing Error Exception in thread "main" org.openqa.selenium .WebDriverException: unknown ...READ MORE

answered Mar 5, 2020 in Selenium by anonymous
9,804 views
0 votes
1 answer

Firefox browser not opening with given URL using Selenium Webdriver with Java

Download the latest selenium jar and replace ...READ MORE

answered Apr 30, 2018 in Selenium by Samarpit
• 5,910 points
7,362 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP