Jar files required to access Selenium class functions - selenium

Currently I have included the following JAR files to playback selenium recordings using JAVA.
junit-4.10.jar
selenium-java-2.24.1.jar
selenium-server-standalone-2.24.1.jar
Also I have imported these packages
import com.thoughtworks.selenium.Selenium;
import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import static org.junit.Assert.fail;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.support.ui.Select;
But with just these, I am not able to access selenium class functions like getAlert() or getConfirmation().
So are there any library files or JAR files that I have missed out on?

You can download the Java Client driver package 2.25.0 from the Selenium HQ site and then add all the jars in your project's referenced libraries.

You didn't imported the DefaultSelenium class which is in com.thoughtworks.selenium package so add this line to your code and it will work.
import com.thoughtworks.selenium.DefaultSelenium;

Related

MobileElement library cannot be found in java-client-8.2.1-all.jar

How can I add MobileElement libary? I am using java-client-8.2.1-all.jar and I have imported io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
I also added the dependency in app > build.gradle
implementation files('libs/java-client-8.2.1-all.jar')
Any idea?
Thanks

error:can't import name 'Protocal' from 'typing'

when i run import ptwtin colab,an error discribed in title occurs,but as I run
from typing_extensions import Protocol,it runs correctly.So how to import ptwt in colab?

Wrong source added (JSONTokener) Intellij

Class JSONTokener is giving an error on the constructor JSONTokener(InputStream in). When I do Alt+Enter and select import class it imports from hive. I have hive and org.json and many others in my pom. I want it to select the correct version. This. I have written it in the pom but I don't understand why it doesn't import from this.
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
If I view the source it doesn't has the required constructor it only as two with String and Reader but not InputStream.
EDIT:
These are the imports
import com.jayway.jsonpath.JsonPath;
import org.apache.commons.io.IOUtils;
import org.apache.nifi.annotation.behavior.SideEffectFree;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.logging.ComponentLog;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.ProcessorInitializationContext;
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.processor.io.InputStreamCallback;
import org.apache.nifi.processor.io.OutputStreamCallback;
import org.apache.nifi.processor.util.StandardValidators;
import org.everit.json.schema.Schema;
import org.everit.json.schema.ValidationException;
import org.everit.json.schema.loader.SchemaLoader;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
And this is the line where it gives compilation error:
JSONObject jsonSchema = new JSONObject(new JSONTokener(getClass().getResourceAsStream("/identification/carrier.json")));
Cannot resolve constructor JSONTokener(java.io.InputStream)

Failed to instantiate class in selenium-cucumber framework

I am using cucumber 3.0.2.My testrunner code is given below.
package futurerx_testrunner_pkg;
import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;
import cucumber.api.CucumberOptions;
#RunWith(Cucumber.class)
#CucumberOptions(features="features/login.feature",glue= {"stepdefinition"})
public class testrunner {
}
I have created 2 packages in src(futurerx_testrunner_pkg and stepdefinition).I have testrunner.java in futurerx_testrunner_pkg package and Basedefinition.java in stepdefinition package.
But when i am running the code,it gives an error "Failed to instantiate class stepdefinition.Basedefinition at cucumber.runtime.java.DefaultJavaObjectFactory.cacheNewInstance(DefaultJavaObjectFactory.java:47) at cucumber.runtime.java.DefaultJavaObjectFactory.getInstance(DefaultJavaObjectFactory.java:33) at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:48)".
I am new to this cucumber-selenium framework and not understanding where i am going wrong.Thanks in Advance.

cx_freeze ignores custom variables module

I'm trying to freeze a small GUI I made using PyQT5, Matplolib and Python 3.3.
I'm a beginner so please pardon my ignorance.
The program has:
- one QMainWindow
- two auxiliary QDialogs with Matplotlib plots
- one Variables_Module that I use to store variables (rather than using global)
- one custom Class called ROI
When running from Python terminal the code works fine.
Issue: When running the exe obtained with cx_freeze QMainWindow is loaded, user chooses data and data is immediately shown in first QDialog. Second QDialog uses variables stored in the "Variables_Module" and should show a matplotlib hist2d but nothing appears.
For this reason I think Variables_Modules does not get included in the build somehow.
the Main.py has these includes:
import sys, time
from PyQt5.QtCore import Qt, pyqtSignal, QObject
from PyQt5.QtWidgets import QWidget, QApplication, QMainWindow, QFormLayout, QVBoxLayout,QFileDialog, QDialog, QPushButton, QGridLayout, QMessageBox, QSlider, QSpinBox, QGroupBox, QLabel, QCheckBox, QComboBox, QColorDialog, QProgressDialog
from HySP_main_GUI import Ui_Main
import numpy
from matplotlib.pylab import *
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QTAgg as NavigationToolbar
from matplotlib.figure import Figure
import matplotlib.pyplot as pyplot
#these are the "custom" modules
import Variables_Module
from ROI import Resizable_animated_rect
from scipy import ndimage
I tried including the "custom" modules in the setup.py in every combination as Includes or includefiles or packages with no solution.
I do understand I'm not supposed to put these modules everywhere but I'm out of ideas.
Also, all files (Main.py, ROI.py, Variables_Module.py) are in the same folder and no errors are given when running cx_freeze build.
The setup.py I'm using is:
import sys
from cx_Freeze import setup, Executable
includes = ["ROI","Variables_Module"]
includefiles = ['ROI.py','Variables_Module.py']
excludes = [ 'Tkinter']
packages = ["ROI","Variables_Module"]
path = []
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {
"includes": includes,
"include_files": includefiles,
"excludes": excludes,
"packages": packages,
"path": path
}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
exe = None
if sys.platform == "win32":
exe = Executable(
script="E:\\Python\\Projects\\test\\test.py",
initScript = None,
base="Win32GUI",
compress = True,
copyDependentFiles = True,
appendScriptToExe = False,
appendScriptToLibrary = False,
icon = None
)
setup(
name = "test",
version = "0.1",
author = 'test',
description = "My GUI!",
options = {"build_exe": build_exe_options},
executables = [exe]
)
It would appear that warnings halt the frozen exe.
Before plotting my new image some warnings regarding NaN were shown and apparently were preventing the app from going on with calculations.
I solved suppressing the warning in the troublesome function using:
import warnings
warnings.simplefilter("ignore")
this solves the problem. Took 2 days. -_-'