How to stop/handle random HTML popup during test execution - Selenium Webdriver - selenium

I'm hoping someone would be able to help me with my query. I've done quite a bit of research online and haven't found any particular solution to it yet.
While running my test case, I sometimes encounter an HTML popup that I'm unable to handle in my script. It is very random (well based on customer behaviour while they are traversing the site) and can popup at any time during the customer journey. Sometimes it doesn't popup at all. When it appears only then an entry is visible inside the DOM.
Basically, it is a livechat window (LivePerson to be precise) suggesting customers that an agent is available to help them complete their order if they wish to do so.
Here is a screenshot:
popup screenshot
The below is available in Firebug when I inspect the element:
<div id="LPMcontainer-1483053256847-0" class="LPMcontainer LPMoverlay" style="margin: -143px 0px 0px -285px; padding: 0px; border-style: solid; border-width: 0px; outline-color: rgb(106, 159, 177); outline-width: 2px; font-style: normal; font-weight: normal; font-variant: normal; list-style: outside none none; letter-spacing: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: normal; word-spacing: normal; background-repeat: repeat-x; background-position: left bottom; background-color: transparent; border-color: transparent; width: 571px; height: 287px; cursor: pointer; display: block; z-index: 107158; position: fixed; top: 50%; bottom: auto; left: 50%; right: auto;">
<div role="button" tabindex="0"><img src="https://www./content/dam/tcom/apps/live-person/live-person-chat-bundles-top.jpg" id="LPMimage-1483053256849-2" alt="" class="LPMimage" style="margin: 0px; padding: 0px; border-style: none; border-width: 0px; outline-color: rgb(106, 159, 177); outline-width: 2px; font-style: normal; font-weight: normal; font-variant: normal; list-style: outside none none; letter-spacing: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: normal; word-spacing: normal; position: absolute; z-index: 600; left: 0px; top: 0px;">
</div>
<img src="https://www./content/dam/tcom/apps/live-person/live-person-chat-bottom.jpg" id="LPMcloseButton-1483053256847-1" alt="" class="LPMcloseButton" style="margin: 0px; padding: 0px; border-style: none; border-width: 0px; outline-color: rgb(106, 159, 177); outline-width: 2px; font-style: normal; font-weight: normal; font-variant: normal; list-style: outside none none; letter-spacing: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: normal; word-spacing: normal; position: absolute; cursor: pointer; z-index: 9999; left: 0px; top: 194px;" data-lp-event="close" role="button" tabindex="0">
</div>
It appears in all browsers.
I'd like to handle it in either of the following ways:
Stop it from loading at all (again due to random nature ).
OR
While the script is being executed, as soon as the window appears, it presses 'No thanks' button (id="LPMcloseButton-1483053256847-1" in the above code) and then continue executing the rest of the steps. Please note that id is dynamic in nature, i.e it's unique every time.
Your help would be highly appreciated.

It may not be random. Some sites that I write automation for have something like this also. After some investigation I found that the dialog always popped up after 30 seconds... it just seemed random because I could be on any page when the 30s was up. After more investigation I found that the site looked for a cookie and if it wasn't found, the dialog would be triggered. I found the cookie that was created after the dialog was closed and created it at the start of the script so that it would no longer open.
I would suggest that you look for an existing cookie that was created for that site and see what's in it. Then browse to the site, wait for the dialog to pop up, and close it. See what changes... if the cookie changes or a new cookie is added, etc. then just mimic that behavior before browsing the site.
NOTE: In my case, I had to intentionally browse to a missing page on the domain, e.g. somesite.com/someerrorpage, to create the cookie without the timer starting. Then I just navigated to the site and continued the script.

I'd say the easiest way to get around this is to create a webdriver wrapper that for every call you would send to webdriver, first check if the dialog is present. If it's present, close it, otherwise send the action over to webdriver.

Related

How to allow wordwrap for labels in tab-bar (QTabbar) in qpdfview?

I have documents with long titles and would like them to appear with its full name in the tabbar in qpdfview.
I researched a lot and found that QT has the functionality to allow stylesheet. I looked in the documentation and found no propriety that allows word wrap for title names of the pdf files.
The stylesheet are located in ~/.config/qpdfview/qpdfview.conf, under [mainWindow] I put
styleSheet="QTabBar::tab { font-size: 12px; margin: 0px; padding: 0px; border: 1px; max-width: 120px; }\nQTabBar::tab:selected, QTabBar::tab:hover { font-size: 12px; background-color: coral; min-height: 24px; titlebar-show-tooltips-on-buttons: true; text-align: right; }"
I'm looking for something that is impossible? Then I have to try to change what are shown in the label of the tabbar.

How to Using Webdriver Selenium to get the value of “style” element

I have below HTML path for which I am trying to capture "Inbox" value but I am not able to find particular element in google chrome using Selenium Webdriver.
HTML Path :
<div style="position: absolute; visibility: inherit; overflow: hidden; cursor: default; color: white; text-align: left; width: 84px; height: 14px; padding-left: 1px; padding-top: 1px; left: 1px; top: 1px; background-color: rgb(102, 0, 153);">Inbox"
<img src="/images/tridown.gif" style="position: absolute; width: 8px; height: 4px; top: 9px; left: 75px;">
</div>"Inbox"
<img src="/images/tridown.gif" style="position: absolute; width: 8px; height: 4px; top: 9px; left: 75px;">
</div>
I think left and top is unique identifer for Inbox dropdown, so can you please help us to write command to get "Inbox" value from above HTML
As Michas and Saritha G suggested, your HTML code is formatted correctly, but having said that. Please use this example below:
<div style="position: absolute; visibility: inherit; overflow: hidden; cursor: default; color: white; text-align: left; width: 84px; height: 14px; padding-left: 1px; padding-top: 1px; left: 1px; top: 1px; background-color: rgb(102, 0, 153);"></div>
If you want to retrieve the value for "style" attribute for the element above, you need to first locate this element:
firefox = webdriver.Firefox()
element = firefox.find_element_by_css_selector("this element css selector here")
attributeValue = element.get_attribute("style")
Then attributeValue should have this following string "position: absolute; visibility: inherit; overflow: hidden; cursor: default; color: white; text-align: left; width: 84px; height: 14px; padding-left: 1px; padding-top: 1px; left: 1px; top: 1px; background-color: rgb(102, 0, 153);"
I am using Python as an example.
Old thread, but still...
I solved this using the value_of_css_property(). In my case, I need to wait a loader disappear. So I used this:
loader = wrapper.find_element(By.ID, "loader_view")
while loader.value_of_css_property('display') == 'block':
sleep(1)
# do some stuff...

border-top-left-radius not working in IE

I'm using IE10 to design something at the moment [Because it needs to be completely compatible with it], and I'm having trouble.
I have two boxes on either side of the page, with an image at the top. The inner top corner is curved using border-top-*-radius, and this is also implemented on the image inside.
CSS:
#rightsidebar {
position:fixed;
width: 300px;
height: 400px;
padding: 10px;
margin: 0px 0 0 500px;
border-top-left-radius: 110px;
-webkit-border-top-left-radius: 110px;
background-color: #ffffff;
border: 2px dashed #000000;
}
#leftsidebar {
position:fixed;
width: 300px;
height: 400px;
padding: 10px;
margin: 0px 0 0 0px;
border-top-right-radius: 110px;
-webkit-border-top-right-radius: 110px;
background-color: #ffffff;
border: 2px dashed #000000;
}
HTML:
<div id="rightsidebar">
<img style="background-color: #000000; width:300px; height:196px; border-top-left-radius:105px; -webkit-border-top-left-radius:110px;" src="{image:right image}">
</div>
<div id="leftsidebar">
<img style="background-color: #000000; width: 300px; height: 196px; border-top-right-radius: 105px; -webkit-border-top-right-radius: 105px;"src="{image:left image}">
</div>
My JSFiddle is here: http://jsfiddle.net/V73G5/
Using IE, you can see that the right container's image isn't doing the same as the left's, even though I just copy and pasted the code and edited it slightly. It does however work on Chrome, which makes me think this may be a bug. Any insight or suggestions on how to resolve this?
EDIT: I've found a way to work around it using:
border-radius: 105px 1px 0 0;
It's not a proper solution, and I've still no clue as to why this happened in the first place, but the 1px is barely noticeable and seems to make it work.
The behaviour of border radius is affected by compatibility mode in IE10.
If you press F12 you can view the developer console and change the compatability settings.
If the Document mode is set to IE7 or IE8 Standards then the border-radius-left: 10px; doesn't work, however if the standards mode is set to IE9 Standards or Standards then it behaves as expected.
download PIE.htc file and attached your css
#rightsidebar {
border-radius: 8px;
behavior: url(/pie/PIE.htc);
}
for more details check below image one.
may it will help you.

Transparent rounded border in Safari

When using an alpha transparency border with rounded corners in Safari, the background clips into the border. This happens even when using background-clip: padding-box. I know that I can simply wrap the h1's in a span/div/etc and give that the border, but I'm wondering if anyone knows if it is possible to do this without any more mark up.
Here is the css I'm using:
h1.inner {
background: #ffa51f;
border-top-right-radius: 60px;
border-bottom-right-radius: 60px;
border-top: 10px solid rgba(33,33,33,.05);
border-bottom: 10px solid rgba(33,33,33,.05);
border-right: 10px solid rgba(33,33,33,.05);
color: #FFF;
display: inline-block;
font-size: 47px;
font-weight: 800;
line-height: 1.2;
padding: 0 .6em 0 0;
position: relative;
text-transform: uppercase;
text-align: left;
background-clip: padding-box;
box-sizing: border-box;
}
h1.inner:before {
background: #ffa51f;
border-top: 10px solid rgba(33,33,33,.05);
border-bottom: 10px solid rgba(33,33,33,.05);
content: "";
position: absolute;
top: -10px;
bottom: -10px;
width: 9999px;
background-clip: padding-box;
box-sizing: border-box;
}
h1.inner:before {
right: 100%;
}
Below is a jsfiddle and screenshot with an example of what I'm talking about.
http://jsfiddle.net/39Xen/
http://imgur.com/Hp2bzBm
Is it posible that what you are asking has been addressed here:
CSS rounded corners bug in Safari?
?
It seems that Safari has some limitation with respect to what you are trying to do.
Hope that helps.

How to get all attributes of dom element using dojo

Is there any way to get all attributes of dom element in DOJO (not specific one like domAttr.get("nodeId", "foo")).
<div style="border-width: 2px; border-color: #000000; border-radius: 0px; -moz-border-radius: 0px; height: 100px; background-color: #FFFFFF; -webkit-border-radius: 0px; position: absolute; z-index: 900; width: 193px; left: 57px; top: 106px;" position="absolute" height="100px" width="193px" background-color="#FFFFFF" border-color="#000000" border-width="2px" z-index="900" -webkit-border-radius="0px" -moz-border-radius="0px" border-radius="0px" left="57px" top="106px"></div>
I want to read all attributes in div tag.
Thanks in advance.
I'm not sure if Dojo has a wrapper for this (I've done a brief search of the 1.8.3 source), but you can use Node.attributes.
Dojo does use Node.attributes in places like here in parser.js. Note the special handling of IE8 and IE6-7, to avoid falling foul of the same traps.