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 13, 2018 in Selenium by Martin
• 4,210 points
404 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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 13, 2018 by Samarpit
• 5,130 points

Related Questions In Selenium

0 votes
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,050 points
1,390 views
0 votes
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,050 points

edited Apr 4, 2018 by nsv999 2,075 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,070 points
464 views
0 votes
1 answer
0 votes
1 answer

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,050 points
134 views
0 votes
1 answer
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,130 points
521 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
124 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,130 points
1,698 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.