The problem is that I can't figure out how to follow a link. The link goes to the page I want when I click on the image, and the desired page opens in a new tab. It's difficult to describe, it's easier to understand from the attached code
<div class="css-1owz1l2">
<span class=" lazy-load-image-background blur lazy-load-image-loaded" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; border-radius: 4px; cursor: pointer; object-fit: cover; display: flex;">
<img style="height: 100%; width: 100%; object-fit: cover; border-radius: 4px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0%;" src="https://public.nftstatic.com/static/nft/zipped/9082041d35194edd87f9078dc9440f7b_zipped.jpeg" sx="[object Object]">
</span>
</div>
You can extract the link from src attribute of img element as following.
In case "css-1owz1l2" class is unique you can do this:
img = driver.find_element_by_xpath("//div[#class='css-1owz1l2']//img")
link = img.get_attribute("src")
Now you can use this link like this:
driver.get(link)
Or by any other way
You can trying catching the image element and clicking on it directly:
# catching the image element
image = driver.find_element_by_xpath("//div[#class='css-1owz1l2']//img")
image.click()
I have a strange problem . I have a non select drop down with Id as below . There is a no select tag I can see in the code for this field just an input tag nor I can see the text contained in the drop down in the DOM after a select a value . StaffSoCategory is the text box , SelectStaffSoCategory is the icon for the drop down down arrow and StaffSoCategoryValue I believe is for the values displayed .
<input type="text" id="StaffSoCategory" style="width: 126px; font-weight: lighter; border: 1px solid gray; height: 25px; float: left; font-size: 12px; color: black; font-family: Arial; background-color: white;" readonly="readonly" class="ui-autocomplete-input" autocomplete="off" disabled="disabled">
<span role="status" aria-live="polite" class="ui-helper-hidden-accessible">4 results are available, use up and down arrow keys to navigate.</span>
<div id="SelectStaffSoCategory" tabindex="0" style="border-style: solid; border-width: 1px 1px 1px 0px; border-color: gray; width: 22px; height: 29px; background-position: center; cursor: pointer; background-image: url('Images/dropdown.png'); background-repeat: no-repeat; float: left; margin-left: 0px; "></div>
***<input id="StaffSoCategoryValue" type="hidden" value="">***
<ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" id="ui-id-4" tabindex="0" aria-disabled="false" style="z-index: 1; display: none; top: 584px; left: 829px; width: 148px;"></ul>
Once I select the first drop down value (the visible text in drop down is "Confirmed") then value comes in tag but not the visible text of the value that I see , something like below
<input id="StaffSoCategoryValue" type="hidden" value="BCK-Yes">
Is there a way to click on the first value in the drop down I tried with this value "BCK-Yes" and it said element is not visible. I tried selecting the input by Id and then trying Keys down and keys enter that also didn't work.
The code I am trying is
JavascriptExecutor js = (JavascriptExecutor)driver;
WebElement revenuePotential = driver.findElement(By.id("SelectStaffSoCategory")); revenuePotential.click();
WebElement revenuePotentialValue = driver.findElement(By.id("StaffSoCategoryValue"));
js.executeScript("arguments[0].click();", revenuePotentialValue);
Console errors I am getting are
StaffSoJsFun.js?v=2019020100000:1 Uncaught TypeError: $(...).autocomplete is not a function
at HTMLDivElement.<anonymous> (StaffSoJsFun.js?v=2019020100000:1)
at HTMLDivElement.dispatch (jquery-2.0.0.js?v=2019020100000:25)
at HTMLDivElement.y.handle (jquery-2.0.0.js?v=2019020100000:25)
(anonymous) # StaffSoJsFun.js?v=2019020100000:1
dispatch # jquery-2.0.0.js?v=2019020100000:25
y.handle # jquery-2.0.0.js?v=2019020100000:25
Access to XMLHttpRequest at '' from origin 'xx.com' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
Well, the input is hidden, so I'm not surprised selenium tells you the element is not visible. Methods that emulate user actions like click() and sendKeys will not be able to affect hidden elements. However, I think the following might work:
First store that element in an object, let's say element and then try the following code to click on that hidden element:
WebDriver driver= new ChromeDriver();
JavascriptExecutor js = (JavascriptExecutor)driver;
driver.get(desiredURL);
//do all the stuff you want to do before `executeScript()`
js.executeScript("arguments[0].click();", element);
Give that a shot?
I have tried below code to click on the fields but getting errors as
"org.openqa.selenium.WeddriverException:unknown error: Element is not clickable at point(138,353). Other element would receive the the click… display: block;>…."
Code:
WebElement el1 = driver.findElement(By.xapth(".//*#id='BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click()", el1);
UI:
Refer Attached Screenshot
HTML code:
<div id="datatab" class="dijitContentPane panel-content dijitStackContainer-child dijitStackContainer-dijitContentPane" style="padding: 0px; overflow: hidden; left: 0px; top: 0px; height: 154px; width: 258px;" selected="true" data-dojo-type="dijit.layout.ContentPane" widgetid="datatab" title="">
<div id="datatabpanel" class="tabpanel" style="height: 100%; overflow:hidden; padding: 0px">
<div class="section-header-outer">
<div id="fieldlistContainer" style="height: 0px;">
<div id="fieldlist" class="dojoDndSource dojoDndContainer" data-dojo-attach-point="containerNode" widgetid="fieldlist">
<div id="category11545">
<div id="field-BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID" class="category11545 field treenode-leaf-label pentaho-listitem dojoDndItem" fieldid="BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID" title="BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID">Patient ID</div>
You are not allowed to click on the div element, rather you can use a workaround to trigger click event by performing "dragAndDrop operation on the same element".
Try below code:
new WebDriverWait(driver, 10).until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[#style='position: absolute; left: 0px; top: 88px; width: 1366px; height: 677px; display: block;']")));
WebElement el1 = driver.findElement(By.xpath(".//*[#id='field-BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click()", el1);
The html you have attached is do not have id attribute with value = BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID. can you just change your xpath from -
WebElement el1 = driver.findElement(By.xapth(".//*#id='BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));
To
WebElement el1 = driver.findElement(By.xapth(".//*[#fieldid='BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));
//or
WebElement el1 = driver.findElement(By.xapth(".//*[#id='field-BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));
I am facing a problem with selenium IDE
I want to select/click any 2 cursors on map page
I can't use the id's because every time you refresh the map you will get another different cursors with different id's, till now i was able to select/click only one cursor on map and I can't select another different one
I used
|clickAt | //map/area/ | |
&
|clickAt | //map/area/ | |
to click at one cursor
so please help me to be able to click another
All cursor details:
map id="gmimap208" name="gmimap208">
<area log="miw" coords="11,0,12,1,13,2,14,3,14,4,14,5,14,6,14,7,14,8,14,9,14,10,13,11,12,12,12,13,11,14,10,15,10,16,9,17,9,18,8,19,7,20,7,20,7,19,6,18,6,17,5,16,4,15,4,14,3,13,2,12,2,11,1,10,1,9,0,8,0,7,0,6,0,5,1,4,1,3,2,2,2,1,4,0,11,0" shape="poly" title="" style="cursor: pointer;">
</map>
<div class="gmnoprint" style="width: 15px; height: 21px; overflow: hidden; position: absolute; opacity: 0.01; left: 373px; top: 370px; z-index: 2000;">
<img style="position: absolute; left: 0px; top: 0px; width: 15px; height: 21px; -moz-user-select: none; border: 0px none; padding: 0px; margin: 0px;" src="/img/property_icons/free/normal.png" draggable="false" usemap="#gmimap226">
<map id="gmimap226" name="gmimap226">
a cursor XPath :
/html/body/div[5]/div[2]/table/tbody/tr/td[2]/div[3]/div[2]/div/div/div[3]/div[2]/div[50]/map/area
a cursor CSS :
html.win body.rtl div.content-for-layout div#page-container table tbody tr td div#Map div div div div div div.gmnoprint map#gmimap83 area
a cursor HTML :
<area log="miw" coords="11,0,12,1,13,2,14,3,14,4,14,5,14,6,14,7,14,8,14,9,14,10,13,11,12,12,12,13,11,14,10,15,10,16,9,17,9,18,8,19,7,20,7,20,7,19,6,18,6,17,5,16,4,15,4,14,3,13,2,12,2,11,1,10,1,9,0,8,0,7,0,6,0,5,1,4,1,3,2,2,2,1,4,0,11,0" shape="poly" title="" style="cursor: pointer;">
Thanks in Advance. :)
You are clicking at the first element twice.
You can specify which element to click on:
//map/area[1]
//map/area[2]
Should get you the first two.