java


Check which value contains property Java WebDriver


I'm almost do NOT know Java, but I'm learning and have to write some tests in it using WebDriver & jUnit :) I have already performed some, looks like:
import org.junit.Assert;
import org.junit.BeforeClass;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class MyTests {
#BeforeClass
public static void allTestsStarted() {
System.out.println("All tests started");
}
#org.junit.Test
public void testImagePresence() throws Exception {
WebDriver driver = null;
try {
driver = WebDriverHelper.create("https://here.goes.path.to.my.site");
WebElement element = driver.findElement(By.className("myImage"));
String imageSrc = element.getAttribute("src");
Assert.assertNotNull(imageSrc);
} finally {
if (driver != null)
driver.quit();
}
}
# and more and more lines like these :)
}
All works fine :) Now I wanna create test that will check which value now contains my property... Maybe it's not clear, example: one element in one moment of time may contains display: block, and other time it may be display: none... So how it's gonna look like in Java? Just interesting is it possible or not, so please... Any help will be greatly appreciated :)
I think you mean "Attributes".
you can get those using getAttribute: e.g element.getAttribute("display");
Allright, since SO has encouraged users to answer our own questions - I'll do it :) All I had to do is simplify my code a bit :) I wrote two CSS rules: .dispBlock { display:block } and .dispNone { display:none } instead inline css and than in test just checked - visible it or not... Looks like:
WebElement el = driver.findElement(By.className("dispBlock"));
Assert.assertEquals(true, el.isDisplayed());
Of course, on page may be a few elements with that class, but as a first step for learning it works perfectly.

Related Links

what is the better design?
Global cursor in Dropbox API v2
What's the best way to share the model between two play framework application?
Java built in monitoring tool
Collapsing toolbar layout with recyclerview need to collapse based on recycler view height
How to log exception stack trace in Json object with out breaking with log4j2
Efficiency of sequential algorithm executed on machine with 60Gb RAM
Joda-Time Period Calculation
How to check if Current Hour falls between certain range
How to set alert cancel on Popup In selenium web driver
How to get all the keys of json in java using Gson or org.json library? [duplicate]
Can someone explain join method in Java Thread class?
Spring Boot PropertySources in test environment
How to get image source and description from html data using Jsoup
How to clear java.lang.IndexOutOfBoundsException in selenium webdriver
Java Reflection: Get type parameter of generic interface from implementation class

Categories

HOME
jdo
asp.net-core
zeromq
path-finding
google-api-php-client
raspberry-pi
spagobi
at-command
sql-server-2016
baqend
applepay
windows-10-universal
here-api
mapserver
qt-creator
circular-dependency
n-gram
visual-studio-2005
iolanguage
systemc
tostring
aurigma
karma-jasmine
ml
autoconf
jasonette
format-specifiers
crosstab
shopware
su
url-scheme
user-interaction
rst2pdf
elasticsearch-net
gsoap
create-table
gtrendsr
framemaker
repo
wpf-controls
bower-install
io-redirection
dynamics-crm-2013
occlusion
theano.scan
elasticsearch-plugin
fedex
android-mediaprojection
react-scripts
jxcore
iso8601
lync-client-sdk
titanium-android
webdriverjs
sonarlint-vs
or-tools
angular-strap
parallel-data-warehouse
setuptools
removechild
android-textview
radtreelist
skobbler-maps
xpath-1.0
wapiti
ford-fulkerson
iis-arr
riak-cs
key-management
fscommand
block-device
camanjs
phalanger
applescript-objc
wordpress-theme-customize
code-access-security
android-radiobutton
uitouch
phpthumb
expected-exception
picturefill
oracle-warehouse-builder
gnu-smalltalk
google-cloud-save
sharp-repository
smtp-auth
cisco-jtapi
bigcouch
netdna-api
window-management
calling-convention
firefox4
temporal-database
yagni
mediarss
zune

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App