First of all, I'd like to apologize for the lack of a serviceable example of what my code looks like. Unfortunately it contains personal information to access a database that has been made available to my university, so I cannot post it. The link to the databse is here:
http://www.studiolegale.leggiditalia.it/#mode=home,__m=site.
Now, if you don't have a proper adblocker, you'll see that a spam popup window appears. I am building a scraper in python using Selenium, and the problem seems to be that I cannot find a way to close that window. I need to get rid of it for the purpose of my project, but I have no idea how. I tried creating an action chain to locate and click the 'X' button, but both the XPath and the ID of said button are dynamic.
I then noticed that the ID of the X button always contains 'close', so I tried writing something like
spamlist = browser.find_element_by_xpath('//div[contains(#id, "close")] ')
spamlist.click
but to no avail. It gives me no error but it doesn't close the window. I admit I am a bit of a beginner, but I really can't think of what I could be doing wrong. Is there something obvious that I am missing?
EDIT 1.1
I have been asked for the HTML code of 'close element' button. Here it is:
<div id="id70a13b6c7dclose70a13b6c7d" style="display: block !important; position: absolute !important; z-index: 10 !important; height: 70px !important; padding: 20px !important; margin-top: -20px !important; margin-left: -20px !important; box-sizing: border-box !important; left: 12px; right: auto; top: 12px; bottom: auto; transform: none; transform-origin: left top;"><div id="id70a13b6c7dclose-cross70a13b6c7d" style="display:block !important;height:30px !important;min-width:30px !important;background:#000 !important;border-radius:5px !important;border:2px solid #fff !important;white-space:nowrap !important;position:relative !important;-webkit-box-sizing:border-box !important;box-sizing:border-box !important;"><div id="id70a13b6c7dcross-container70a13b6c7d" style="overflow:visible !important;-webkit-box-sizing:border-box !important;box-sizing:border-box !important;"><div id="id70a13b6c7dcross70a13b6c7d" style="position:absolute !important;height:20px !important;width:20px !important;top:3px !important;left:3px !important;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOAgMAAABiJsVCAAAADFBMVEUAAAD///////////84wDuoAAAAA3RSTlMAgGJiSVzhAAAAOElEQVQI12PQYGBqYNjLwP6AYb+D/AMG+Qv1DgzsX/8yMDD+/8LAwFB/AUxAuGAJsBKwYrA2sAEADzMWbZHdzhcAAAAASUVORK5CYII=) !important;background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTQiIGhlaWdodD0iMTQiIHZpZXdCb3g9IjAgMCAxNCAxNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNLjcgMi43Yy0uNC0uNC0uNC0xIDAtMS40bC42LS42Yy40LS40IDEtLjQgMS40IDBMNyA1IDExLjMuN2MuNC0uNCAxLS40IDEuNCAwbC42LjZjLjQuNC40IDEgMCAxLjRMOSA3bDQuMyA0LjNjLjQuNC40IDEgMCAxLjRsLS42LjZjLS40LjQtMSAuNC0xLjQgMEw3IDlsLTQuMyA0LjNjLS40LjQtMSAuNC0xLjQgMGwtLjYtLjZjLS40LS40LS40LTEgMC0xLjRMNSA3IC43IDIuN3oiIGZpbGw9IiNGRkYiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==), linear-gradient(transparent, transparent) !important;background-size:20px !important;overflow:visible !important;-webkit-box-sizing:border-box !important;box-sizing:border-box !important;"></div></div><div id="id70a13b6c7dcounter70a13b6c7d" style="display:none !important;text-align:center !important;position:absolute !important;min-height:30px !important;min-width:30px !important;color:#fff !important;font:small-caps bold 18px/30px courier new, sans-serif !important;overflow:visible !important;-webkit-box-sizing:border-box !important;box-sizing:border-box !important;"></div></div></div>
Chances are there that the pop up is in iframe.
So you need to switch to the frame before closing the pop up.
Driver.SwitchTo().frame("frame xpath");
Driver.findElement("enter your xpath to close popup").click();
Driver.SwitchTo().defaultContent();
Related
Is there a way to fix the vertical layout of the PagerSettings when displayed at the bottom of a grid?
UPDATE: I am working on build 19.110.0013
I am trying to add numbers to the bottom of a grid using the PagerSettings tag described in the post Add page numbers to the bottom of Process Shipments grid. When I set the PagerVisible to bottom the numbers display vertical, but if I set the PagerVisible to top the numbers are properly displayed as horizontal.
<ActionBar PagerVisible="Bottom" DefaultAction="cmdItemDetails">
<PagerSettings Mode="Numeric" LinksCount="5" />
</ActionBar>
I could not reproduce that behavior in Acumatica version 19.106.0020 so I manually tweaked the CSS in order to reproduce that glitch.
Setting 'display: block' CSS property on GridPagerLink CSS class reproduces the same rendering.
In file '\App_Themes\Default\00_Controls.css' it is set as 'display: inline-block;'.
Inline option will make them stack horizontally so I don't have this glitch on my side.
Which exact Acumatica version are you running?
Use browser HTML inspect element feature to inspect the GridPagerLink.
Does it look like the default style below?
.GridPagerLink {
display: inline-block;
color: RGBA(0, 0, 0, 0.87);
text-decoration: none;
font-size: 15px;
font-weight: bold;
padding: 5px 10px;
height: 18px;
border: solid 1px transparent;
}
I'm looking to sort a webpage from low price to high price by using the built-in product sort
I am able to successfully select the correct dropdown menu using xpath as follows:
WebDriverWait(driver, 5).until(
EC.element_to_be_clickable((By.XPATH,
'//*[#id="react-views-container"]/div/div/div/div[1]/div/div/div/div[2]/div[1]/div/div[2]/div/div[1]/button')))
This was intended only to be a test of sorts, as I am still relatively new to selenium. However, given this worked I cannot understand why the following does not:
WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.XPATH,
'//*[#id="react-views-container"]/div/div/div/div[1]/div/div/div/div[1]/div/div[1]/div/div[2]/div/div/div/div/div[4]')))
This results in an error whereby the timeout is reached. It is not an issue of the timeout being too short. I have tried the div search for the given text, but that also did not work. Here is one example of the search I tried which was nearly copied from a similar question:
Select(driver.find_element_by_xpath("//div[contains(text(), 'Unit Price: Low First')]"))
Here is the HTML for the desired menu item:
<div role="menuitem" tabindex="0" data-radium="true" style="background-color: rgb(247, 247, 247); padding: 8px 16px; font-size: 16px; font-weight: normal; color: white; white-space: nowrap; line-height: 20px; min-width: 260px; height: 36px; cursor: pointer;">
<div data-radium="true" style="float: left; display: block; line-height: 24px;">Unit Price: Low First</div>
</div>
Ok so that was a bit of a painful lesson in html and Selenium. Anyway, I figured it out by creating a list of all the menu items and then iterating through that list and clicking on the one I wanted. At the moment, I have this:
menu_items=driver.find_elements_by_xpath('//div[#role="menuitem"]')
for i in menu_items:
if "Unit Price" in i.text:
i.click()
break
For some reason I cannot just do menu_items[4].click(), but I believe it is due to the elements list being a list of tuples or something, though I will have to check the documentation to verify this. I will update the answer afterwards.
just getting started on react-leaflet and leaflet. After clicking on a marker I want to have a full screen overlay above the map to display a graph. But no matter how I set z-index of the and , the overlay always lies below the map.
Couldn't find an answer as most z-index question apply to map layers etc. within the component.
.overlay-wrapper {
position: fixed;
display: block;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: rgba(0,0,0,0.5);
z-index: 200;
cursor: pointer;}
It should be pretty straight forward, please point me in the right direction.
As #andreasgroos mentioned in their comment, the z-index value needs to be high enough, i.e. 401 or higher. z-index: "2000 !important" should guarantee that the component will be rendered over the map.
When SCAYT find a wrong world it will add a style to span with wrong worlds like that :
.scayt-enabled [data-scayt_word] {
background: url("data:image/gif;base64,R0lGODlhBAADAIABAP8NDQAAACH5BAEAAAEALAAAAAAEAAMAAAIFRB5mGQUAOw==") repeat-x scroll center bottom transparent !important;
padding-bottom: 0 !important;
text-decoration: none !important;
white-space: nowrap !important;
}
But it`s broke my parent style "word-wrap: break-word". How is possible to override this style?
delete white-space: nowrap rule, or !important, or trie something else and tell us about it. have you tried anything btw?
I am quite new to XHTML/CSS, but have now got my site laid out nicely. Just one loose end which I can't seem to get past (I've spent a fair bit of time on this & found related info, but nothing quite the same):
All I want to do is overlay a faint image on my background. I don't want to use the "opaque" filters, as they trigger the script security alert on my IE Explorer 8.
I am quite happy to use the opaque gif image I have created.
I can see that z-index is the way to go. However, my image area insists on locating further down the page rather than overlaying.
Here's what I think are the key extracts of the code where I am going wrong [I have snipped detail such as fonts]:
HTML:
body { position:relative; z-index:1;
margin: 0 20px 0 0;
padding: 0;
background: #FFFFFF url(images/ge01.jpg) repeat-y;[snip]}
<div id="transparency">
</div>
CSS:
#transparency {
url(images/transparency.jpg) no-repeat;
width:230px;
height: 1000px;
position: relative; top: 80px; left:0;
z-index:2;
}
Have you tried using position: absolute; on your transparency element?
position: relative means that you will position the transparent element in relation to other content.