How to get tool tip text using selenium web driver - webdriver

I am trying to get tool tip text of image and wanted to store in variable. Below is the HTML Code.script is able to perform the mouse hover event and showing the tool tip text value .but unable to get tool tip text value.Please help me on this.
<img onmouseover="var relNo=getReleaseNo(); this.T_ABOVE = false; this.T_OFFSETY=-10; this.T_OFFSETX=10; this.T_WIDTH=200; this.T_DELAY=1000; return escape('<table><tr><td align=center>Welcome to the Daimler EngineeringPortal<br><b>' + relNo + '</b></td></tr></table>');" src="./pics/logo/logo_mini.jpg">
PFA Below mentioned is selenium scripts. In script all thing is working exppect unable to get the text.
Selenium Script
package All_Module_Engp;
import java.io.File;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
public class Engp_Module {
public static void main(String args[])
{
File pathToBinary = new File("C:/Users/rrimjhi/AppData/Local/Mozilla Firefox/firefox.exe");
FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
FirefoxProfile firefoxProfile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(ffBinary,firefoxProfile);
driver.get("https://tindito.COM");
driver.findElement(By.id("usr")).sendKeys("xyz123");
driver.findElement(By.id("password")).sendKeys("xyz123");
driver.findElement(By.name("login")).click();
driver.manage().window().maximize();
// String s = driver.getTitle();
// System.out.println(s);
Actions tooltip = new Actions(driver);
driver.switchTo().frame("header");
WebElement img1=driver.findElement(By.xpath("//img[#src='./pics/logo/logo_mini.jpg']"));
tooltip.clickAndHold(img1).perform();
String ToolTipText = img1.getText();
System.out.println(ToolTipText);
}
}

Try this:
WebElement elementWithTooltip = driver.findElement(By.xpath("//img[#src='./pics/logo/logo_mini.jpg']"));
Actions builder = new Actions(driver);
builder.moveToElement(elementWithTooltip).build().perform();
//try to find this tool tip element and verify the text
WebElement tooltip = driver.findElement(By.id("tooltip"));
assertEquals("tooltip content", tooltip.getText());

Related

the method .add(node) doesn't allow me to use Button. JavaFX [duplicate]

Ok so from my stand point my code is pretty decent enough to get a passing grade but I am having trouble adding a simple refresh/shuffle button. NOT USING the aids of JOptionPane.
Eclipse doesnt seem to recognize that I have created the button which doesnt make sense at all for me because its telling me something about a Node which the Button is in fact a node and it is created. But when I go into another class and add another button with the 3 line example it simply works. But when I move it to my homework program it simply gives me an error on the add method which breaks the whole program!
Says
"The method add(Node) in the type List is not applicable for the arguements (Button)"
Could anyone shed some light of where I could be going wrong in my code? It has to be something along the a node to string conversion or something I just cant seem to figure it out. Willing to take any hints given to me but please DO NOT SOLVE THE PROBLEM FOR ME.
Here is the question from the book basically.
"Write a program that lets the user click the refresh button to display four cards from a deck of 54 cards."
I just need some help on the button thats all. I literally have the rest.
Here is my code so far.
I Have left the imports out as there is just too many.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.stage.Stage;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import java.awt.Button;
import java.io.File;
import java.util.ArrayList;
public class Cards extends Application
{
public void start(Stage primaryStage)
{
ArrayList<String> cards = new ArrayList<>(); //Array list
Shuffle(cards); //Shuffles the Cards
String file1 = new File("cards" + "/" + cards.get(1) + ".png").toURI().toString();
String file2 = new File("cards" + "/" + cards.get(2) + ".png").toURI().toString();
String file3 = new File("cards" + "/" + cards.get(3) + ".png").toURI().toString();
String file4 = new File("cards" + "/" + cards.get(4) + ".png").toURI().toString();
Pane pane = new HBox(20); //Creates the Box for the Images
pane.setPadding(new Insets(5, 5, 5, 5)); //Spreads the Images out
Image image = new Image(file1); //Creates the String Image
Image image2 = new Image(file2);
Image image3 = new Image(file3);
Image image4 = new Image(file4);
pane.getChildren().add(new ImageView(image)); //Adds the First Image
ImageView view1 = new ImageView(image);
view1.setFitHeight(100);
view1.setFitWidth(100);
pane.getChildren().add(new ImageView(image2)); //Adds the Second Image
ImageView view2 = new ImageView(image2);
view2.setFitHeight(100);
view2.setFitWidth(100);
pane.getChildren().add(new ImageView(image3)); //Add the Third Image
ImageView view3 = new ImageView(image3);
view3.setFitHeight(100);
view3.setFitWidth(100);
pane.getChildren().add(new ImageView(image4)); //Add the Fourth Image
ImageView view4 = new ImageView(image4);
view4.setFitHeight(100);
view4.setFitWidth(100);
HBox hbox = new HBox(5); //Creates the Box for the Button
Button shuffle = new Button("Shuffle"); //Creates the Button
hbox.getChildren().add(shuffle); //Should add the button but doesn't
shuffle.addActionListener( e -> //Listener for the button
{
Shuffle(cards);
});
BorderPane pane2 = new BorderPane();/ /Creates the Pane for the Button
pane2.setCenter(pane); //Sets the cards in the Center
pane2.setBottom(hbox); //Sets the Button on the bottom
BorderPane.setAlignment(hbox, Pos.CENTER);
hbox.setAlignment(Pos.BOTTOM_CENTER);//Aligns the Button to BOT_CENTER
Scene scene = new Scene(pane2); //Creates the Scene
primaryStage.setTitle("Cards");
primaryStage.setScene(scene);
primaryStage.show();
}
public void Shuffle(ArrayList<String> cards)
//Allows the cards to Shuffle when called.
{
for (int i = 0; i <= 53; i++) //Sets the Number of Cards in Deck
cards.add(String.valueOf(i+1));
java.util.Collections.shuffle(cards);
}
public static void main(String[] args)
{
launch(args);
}
}
You're using the AWT-button with your import java.awt.Button;, that's why you can use the method public void addActionListener(ActionListener l).
Replace your import to import javafx.scene.control.Button;. Furthermore you could use (analogue to your code) the following lambda:
shuffle.setOnAction( (x) -> //Listener for the button
{
Shuffle(cards);
});
Give it a try :)

jxbrowser -- jquery.AreYouSure .. warning message always in English...

i trying to use jquery.AreYouSure into JxBrowser(5.2 and/or next version).
jquery.AreYouSure works... but the warning pop up windows is always in english...
This behaviour is wrong and differ from chrome/firox/ie.... these show message in the current language...
this is a demo url
http://www.papercut.com/products/free-software/are-you-sure/demo/are-you-sure-demo.html
By default, JxBrowser displays dialogs configured with English language. At the same time, JxBrowser API provides functionality that allows modifying default behavior and display your own dialogs with required language. To change the language you need to register your own DialogHandler where you can display your own dialog. For example:
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.CloseStatus;
import com.teamdev.jxbrowser.chromium.UnloadDialogParams;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
import com.teamdev.jxbrowser.chromium.swing.DefaultDialogHandler;
import javax.swing.*;
import java.awt.*;
/**
* The sample demonstrates how to catch onbeforeunload dialog.
*/
public class BeforeUnloadSample {
public static void main(String[] args) {
Browser browser = new Browser();
final BrowserView view = new BrowserView(browser);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(view, BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setVisible(true);
browser.setDialogHandler(new DefaultDialogHandler(view) {
#Override
public CloseStatus onBeforeUnload(UnloadDialogParams params) {
String title = "Confirm Navigation";
String message = params.getMessage();
int returnValue = JOptionPane.showConfirmDialog(view, message, title, JOptionPane.OK_CANCEL_OPTION);
if (returnValue == JOptionPane.OK_OPTION) {
return CloseStatus.OK;
} else {
return CloseStatus.CANCEL;
}
}
});
browser.loadHTML("<html><body onbeforeunload='return myFunction()'>" +
"<a href='http://www.google.com'>Click here to leave</a>" +
"<script>function myFunction() { return 'Leave this web page?'; }" +
"</script></body></html>");
}
}

Mediaplayer in JAR

This code compile in Intellij, but it does not work in jar.
Working with getResourceAsStream() or getResource doest not solve the problem.
(I have tried out with Image like Image image = newImage(getClass().getResourceAsStream("image.png");and it does work)
package Sound;
import javafx.application.Application;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.stage.Stage;
import javafx.util.Duration;
import java.io.File;
/**
*/
public class TestSound extends Application{
public TestSound() {
play();
}
#Override
public void start(Stage primaryStage) throws Exception {
new TestSound().play();
}
private void play(){
String mainsound = "src/res/sound/main.mp3";
Media i = null;
i = new Media( new File(mainsound).toURI().toString());
MediaPlayer mediaPlayer = new MediaPlayer(i);
mediaPlayer.play();
mediaPlayer.setStopTime(new Duration(120000));
mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE);
}
public static void main (String[] args){
launch(args);
}
}
EDIT:
Media i = new Media(getClass().getClassLoader().getResource(mainsound));
wont work, because the constructor need a String.
but also
Media i = new Media(getClass().getClassLoader().getResource(mainsound).toString());
new MediaPlayer(i).play();
does not work.
ofcourse mainsound="res/sound/main.mp3";
After extraction of jar with winrar
I got dictionary of sound with include the
testsound.class and main.mp3
And another dictionary of res with include main.mp3
Both dictionary are in the same root.
getClass().getResource("res/sound/main.mp3") is going to look for a resource named res/sound/main.mp3 relative to the current class. Since your class is in the sound package, it's effectively going to look for /sound/res/sound/main.mp3, which is not where the resource is located in your jar.
If the list of entries in the jar file is showing
/sound/main.mp3
then the following should work:
String mediaURL = getClass().getResource("/sound/main.mp3").toExternalForm();
// for debugging:
System.out.println(mediaURL);
Media i = new Media(mediaURL);
Instead of using getClass ().getResource (...) it would be ideal to use it like
Media m = new Media ("/myMedia.mp3");//if the media exists in default package
or
Media m = new Media ("/mypackage/myMedia.mp3");//if the media exists in mypackage

Using SQLite in BlackBerry

I am new to blackberry development. I am trying to make an application where I have to save name and three checkbox results(i.e. whether boxes have checked or not). I have created a screen. But I am not able to save the data in database and I think of using SQLite.
Please help me and tell how can I proceed and I have a confusion that where I will write the coding for database i.e. In the main screen class or I have to create another separate class.
Here is the coding for mainscreen.
package medicine;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.CheckboxField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.UiApplication;
public class EnterSuccessScreen extends MainScreen implements FieldChangeListener{
EditField nameField;
CheckboxField medicineCheckbox1;
CheckboxField medicineCheckbox2;
CheckboxField medicineCheckbox3;
ButtonField submitButton;
public EnterSuccessScreen(){
add(new LabelField("Please enter your details:"));
add(new SeparatorField());
nameField = new EditField("Medicine Name:", "");
add(nameField);
add(new SeparatorField());
add(new SeparatorField());
add(new LabelField("Time To Take the Medicine:"));
medicineCheckbox1 = new CheckboxField(" 9 a.m.", false,Field.FIELD_LEFT);
add(medicineCheckbox1);
medicineCheckbox2 = new CheckboxField(" 12 p.m.", false,Field.FIELD_LEFT);
add(medicineCheckbox2);
medicineCheckbox3 = new CheckboxField(" 3 p.m.", false,Field.FIELD_LEFT);
add(medicineCheckbox3);
add(new SeparatorField());
submitButton = new ButtonField("Submit", ButtonField.CONSUME_CLICK);
add(submitButton);
submitButton.setChangeListener(this);
}
public void fieldChanged(Field field, int context){
if (field == submitButton) {
submit();
}
else{}
}
private void submit(){
SubmitSuccessScreen submitSuccessScreen = new SubmitSuccessScreen();
UiApplication.getUiApplication().pushScreen(submitSuccessScreen);
}
}
Blackberry gave some sample demos for your problem you check on SqliteDemo in blackberry sample demos.

Flex: type was not found or was not a compile-time constant: Button

I am trying to build a pure as3 project in flex and I got the following error:
type was not found or was not a compile-time constant: Button
type was not found or was not a compile-time constant: TextField
My code is:
import fl.controls.TextInput; // import my textinput
import flash.display.Shape;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.text.TextField;
import fl.controls.Button; //import my button
public class SearchYoutube extends Sprite
{
private var textBx:TextField=new TextField();
private var controls:Controls;
private var bground:Sprite=new Sprite();
private var searchButton:Button;
/************************Constructor*********************/
public function SearchYoutube()
{
/*********************Create Search Form****************************/
createSearchForm("Please Enter Your Keyword");
}
/*********************Search Form****************************/
private function createSearchForm(title:String):void{
var searchInput:TextInput = new TextInput(); //error here
searchInput.width = 200;
searchInput.x=150;
searchInput.y=450;
searchKeyword=searchInput.text;
addChild(searchInput);
searchButton = new Button(); //error here
searchButton.x = 380;
searchButton.y = 450;
searchButton.label = "Search";
addChild(searchButton);
}
}
}
I appreciate any helps!
Agree with the above answer, and add that Button is in package mx.controls.
Use imports
import mx.controls.Button;
import mx.controls.TextInput;
Also to address other comments, doesn't "actionscript only" just mean no mxml and .mxml files? It's still a .as files only.
Haven't done any Flash coding for a while, but I seem to remember that all of the fl. Your Flex Builder can't see those two classes. Scrolling through the language reference there is no fl package, so I would say you need to change those two classes to something that exists in Flex like flash.display.Sprite (with buttonMode on) and flash.text.TextField
http://livedocs.adobe.com/flex/3/langref/

Resources